Wednesday, August 15, 2012

julian date conversion script


--date to julian 
(select (100+year('05-01-2010')-2000)*1000+ datediff(d, convert(datetime,('01/01/'+convert(char(4),year('05-01-2010')))),'05-01-2010')+1) 


-- julian to date format
select DATEADD(day, CAST(RIGHT(112228,3) AS int)-1,
dateadd(yy, 112228/1000, 0))

No comments:

Post a Comment