469,927 Members | 1,868 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Converting Integers to DateTime

Hello,

Is there a better way to convert separate integer values, representing Day, Month, Year, Hour, Minute and Second to DateTime?

I work in the Automation Industry and PLC (Programmable Logic Circuits) programs often store Date/Time in this format.

The best I can work out is like this...

Declare @Day Int
Declare @Month Int
Declare @Year Int

Set @Day = 1
Set @Month = 2
Set @Year = 2007

Select DateAdd(dd, @Day-1, DateAdd(mm, @Month-1, DateAdd(yy, @Year-1900, '1900-01-01')))
Jun 4 '07 #1
0 1006

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by M. Uppal | last post: by
8 posts views Thread by Mika M | last post: by
3 posts views Thread by NateM | last post: by
reply views Thread by marc.wyburn | last post: by
6 posts views Thread by minboymike | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.