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
 Convert fromVarchar to datetime

Author  Topic 

nastavirs
Starting Member

2 Posts

Posted - 2009-03-16 : 14:49:53
I have a column which is of type varchar and contains date values like 03/16/2009 13:29:13

I have to copy this to a column (in the same table) of type datetime.

Kindly help!

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-03-16 : 14:54:22
You can just do an update ...There is no need for any conversion.

update urtable set col_datetime = col_varchar

Your new datetime column will have values as below.
2009-03-16 13:29:13.000
Go to Top of Page

nastavirs
Starting Member

2 Posts

Posted - 2009-03-16 : 15:19:17
Thanks for the immediate reply.
It worked
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-03-16 : 15:43:22
Great. Good luck!
Go to Top of Page
   

- Advertisement -