Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
HI I have a date field which has been imported as a varchar.I.eDoc_date25/03/200700/00/0000etc...As you can see the data entered did not have very good validation.How can I convert the dates into the following format?Doc_date25/03/2007 --> 25 Mar 200700/00/0000 --> blank or null....many thanks!!
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2007-03-28 : 11:16:36
SELECT CONVERT(VARCHAR(11), NULLIF(Doc_date, '00/00/0000'), 106)FROM Table1Peter LarssonHelsingborg, Sweden
dnf999
Constraint Violating Yak Guru
253 Posts
Posted - 2007-03-28 : 18:10:44
But that doesn't get it in the format:25 March 2007 from 25/03/2007.Is there any way to do this?Thanks in advance.
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2007-03-28 : 19:17:12
why do you want to convert from string to string ? why not convert from string to datetime ?
In your ORIGINAL POSTING, you wanted 25 Mar 2007.Peter LarssonHelsingborg, Sweden
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2007-04-02 : 03:11:22
quote:Originally posted by dnf999 But that doesn't get it in the format:25 March 2007 from 25/03/2007.Is there any way to do this?Thanks in advance.
Where do you want to show formatted dates?If you use front end application, use format function thereMadhivananFailing to plan is Planning to fail
dnf999
Constraint Violating Yak Guru
253 Posts
Posted - 2007-04-02 : 18:44:58
I am exporting the results from sql to excel. Unfortunately, I do not work in an environment where data is taken from a highly validated front end....:(