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)
 How to convert int to datetime

Author  Topic 

imughal
Posting Yak Master

192 Posts

Posted - 2009-10-23 : 07:52:48
Hi,

i have table mytable with

sno as int
sdate as int

sdate date has already values like

20090731
20090731
20090731
20090731
20090731

i have create new filed newdate as datetime, now to update this field from sdate with new column should have data in date format pls tell how to do that.

thx

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-23 : 08:18:25
update table
set newdate=convert(datetime,convert(varchar(8),sdate))


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -