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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 converting a date '17 | 9-2008' into '9-17-2008'

Author  Topic 

sqlchiq
Posting Yak Master

133 Posts

Posted - 2008-08-18 : 18:45:30
I have a column with dates in the above formate (i know, weird),

17 | 9-2008
10 | 9-2008
27 | 8-2008
20 | 8-2008
16 | 8-2008
13 | 9-2008
13 | 8-2008
23 | 8-2008

is there anyway to turn those into your standard 8/23/2008 or default smalldatetime format?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-18 : 19:07:47
What does the data look like for October-December? Is there a space after "|"?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-08-18 : 19:19:56
You might try something like: STUFF(RIGHT(MyCol, 7), 4, 0,LEFT(MyCol, 2)+ '-')
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-18 : 20:01:48
convert it to datetime or smalldatetime

select convert(datetime, replace(datecol, ' | ', '-'), 103)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -