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
 how to create a date from integer

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2007-05-03 : 08:58:54
year=2004
month=1
day=1
how to create a date from that?
date(year, month, day) does not seem to work.

Thanks.

Jeff

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-03 : 09:04:06
http://weblogs.sqlteam.com/jeffs/archive/2007/01/02/56079.aspx

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

spejbl
Starting Member

28 Posts

Posted - 2007-05-03 : 09:04:37
[code]SELECT CAST(CAST(@Year AS VARCHAR(4))+'0101' AS DATETIME)[/code]

--
Tom
Microsoft KB articles monitoring | Apple KB articles monitoring
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-03 : 09:10:06
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=22339


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-05-03 : 09:25:54
Avoid CAST and CONVERTS whenever possible; math is much better than converting data to and from concatenated strings in various formats.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -