Question

I am working with a legacy system whereby it seems they store dates as integers, such as 733473. Anyone seen this format before and can think of the logic to turn this into a date? It appears to be a day number, but not sure how many days from what date!

Edit: the value I get for 01/01/2013 is 734869. It is the amount of days since 0 i believe, but does this have a name? I need to write/find a native function in MSSQL server to convert these.

No correct solution

OTHER TIPS

You are most likely correct, it's the number of days since Jan 1, year 0000 (or possibly 1).

$ date -u -d "0000-01-01 + 733473 days"
Fri Mar  7 00:00:00 UTC 2008

However, without knowing the date it actually corresponds to, we can't know for sure which leap year system it follows.

OK not sure the name of this date type (if there is one), but the below works:

declare @dt datetime2 = '00010101'
declare @int int = 734869

select dateadd(day,@int-1,@dt)

2013-01-01 00:00:00.0000000
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top