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
 Varchar to datetime

Author  Topic 

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2009-01-21 : 05:33:12
I have in a varchar "27/01/2009 00:00:00"

How do I write the conversion of this into a datetime type?
The time is unimportant just the date bit I am interested in.



Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-01-21 : 05:39:32
select convert(datetime,'01/27/2009 00:00:00')
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-21 : 05:41:24
declare @date varchar(32)
set @date ='27/01/2009 00:00:00'
select convert(datetime,@date,103)
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-01-21 : 05:45:06
select cast('01/27/2009 00:00:00' as datetime) as date
Go to Top of Page

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2009-01-21 : 05:58:08
Thank you very much guys.
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-21 : 05:59:48
welcome
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-21 : 08:39:29
always try to use universal dateformat like '2009-01-27 00:00:00'
Go to Top of Page
   

- Advertisement -