Link to home
Start Free TrialLog in
Avatar of dchinen
dchinen

asked on

T-SQL Convert Julian Date to Standard Date Format

Hello,

Could someone tell me how what the syntax is to convert a Julian date to a regular date format in SQL?  Thanks.

d-
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

if you're juliandates are like 2003200 then you could try something like

select NormalDate = dateadd ( dd , ( 2003200 % 1000 ) - 1 , convert ( datetime ,convert( char(4) , 2003200 / 1000 ) + '/01/01') )
And try this:

DECLARE @InputDate VARCHAR(30)
SET @InputDate = '2002365'
SELECT DATEADD(dd,CAST(RIGHT(@InputDate, 3) AS INT) - 1, '01/01/' + LEFT(@InputDate, 4))
AS [Result]
Avatar of dchinen
dchinen

ASKER

Wow, there is no built in T-SQL function for this?  Okay, I'll try your suggestions.    Thanks a million!

ASKER CERTIFIED SOLUTION
Avatar of sanjaykp
sanjaykp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, read Julian Day Number rather than Julian Date Number.

Cheers
Avatar of dchinen

ASKER

thanks, that's what i was looking for.