Reputation: 41
I have an integer field as containing a represent DATETIME value, how to can convert a datetime format..
the value, represent datetime
6843438 is a 04/01/2013 09:18
6843660 is a 04/01/2013 13:00
try to
select dateadd(hour,6843438,'19700101') -->> error
select dateadd(hour,843438,'19700101') -->> 2066-03-21 06:00:00.000 is bad
any idea?
Upvotes: 4
Views: 475
Reputation: 432261
Well, it isn't hours because you get 09:18. So it's probably minutes.
We can verify that thus, and also work our roughly how many years there are
SELECT
6843438 /60 /24 /365, --years = 13
6843438 /60, --hours = 114957 (not really useful)
6843438 % 60 --minutes = 18
So, if you change the Epoch to 01 Jan 2000, it works
select
dateadd(minute,6843438,'20000101'),
dateadd(minute,6843660,'20000101')
Upvotes: 5