Does SQL Server have any built-in functions to work with julian dates?

Neil Pike

March 4, 1999

1 Min Read
ITPro Today logo

A. No, you have to code your own sp. Here is some sample code -originally from Roy Harvey.

  1. Assuming the Julian date is held as a char
    declare @julian char(8)
    select @julian='1996.031'
    declare @dt datetime

    select @dt=DATEADD(dd,convert(int,right(@julian,3))-1,convert(datetime,substring(@julian,1,4)+'0101',212))

    select @dt

  2. Julian date in decimal format - e.g. 99123 is 123rd day of 1999 held invariable SDDRQJ.
    selectDATEADD(day,CONVERT(int,SDDRQJ)-((1000*(CONVERT(int,SDDRQJ)/1000)))-1,DATEADD(year,CONVERT(int,SDDRQJ/1000),'1 Jan 1900'))

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like