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 2000 Forums
 SQL Server Development (2000)
 Convert Char to Datetime

Author  Topic 

Amjath
Yak Posting Veteran

66 Posts

Posted - 2007-02-05 : 22:15:02
Hi All,

I have the Date in form of char like this
'Tuesday, February 06, 2007, 10:58:18'

PLz help me to convert this type of char date to DateTime support by sql server.

But i try to convert this using the following, but it show some error.
SELECT convert(datetime, 'Tuesday, February 06, 2007, 10:58:18')

-Amjath

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-05 : 22:22:39
[code]
declare @str varchar(100)

select @str = 'Tuesday, February 06, 2007, 10:58:18'

SELECT convert(datetime, replace(substring(@str, charindex(',', @str) + 1, 50), ',', ''), 109)

[/code]


KH

Go to Top of Page

Amjath
Yak Posting Veteran

66 Posts

Posted - 2007-02-05 : 22:37:22
Thanks a lot, its working fine

-Amjath
Go to Top of Page
   

- Advertisement -