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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Cast/Convert String To Date

Author  Topic 

denfer
Starting Member

12 Posts

Posted - 2009-03-31 : 09:04:20
Hi
I have a date String 'Feruary 13th, 2009' that I want to convert to Date.
I tryed several way without any success
do you have any idea if this kind of string can be converted/Cast to DateTime ?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-31 : 09:13:10
[code]DECLARE @Sample VARCHAR(200)

SET @Sample = 'February 13th, 2009'

SELECT @Sample,
CAST(REPLACE(@Sample, 'th', '') AS DATETIME)[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-31 : 09:20:43
you also might want to add replacements for 'st','rd','nd'..
Go to Top of Page

denfer
Starting Member

12 Posts

Posted - 2009-03-31 : 09:22:14
Thanks a lot for your help
I didn't noticed the missing 'b'
Go to Top of Page
   

- Advertisement -