I have seen numerous examples on the web and a few here on SO. However, none seem to work for my data. Here are a few julian dates with their known converted values.
JUL | DateTime
2454522 | 2008-02-25 00:00:00.000
2454571 | 2008-04-14 00:00:00.000
2455713 | 2011-05-31 00:00:00.000
I have tried this which does not work:
DECLARE @JD int = 2454522
SELECT DATEADD(YEAR, @JD / 1000 - 1900, @JD % 1000 - 1)
It gives me this: 2455-06-06 00:00:00.000 which is obviously wrong. What am I missing here? Thanks ind advance.
One approach that should work in SQLServer:
select @jd, dateadd(d,@jd - 2440588,'1970-01-01')
SQLFiddle here.