Skip to content

Instantly share code, notes, and snippets.

@JohnLBevan
Created January 25, 2014 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnLBevan/65eda22a8550c8c26b6b to your computer and use it in GitHub Desktop.
Save JohnLBevan/65eda22a8550c8c26b6b to your computer and use it in GitHub Desktop.
SQL Server code to convert JDEdwards Julian Dates to dates / formatted strings From http://sqlfiddle.com/#!3/d41d8/28945
declare @JulianDate integer = 114026;
select DATEADD(day,@JulianDate%1000-1,CAST(cast(@JulianDate/1000 + 1900 as varchar(4)) + '-01-01' as date)) ActualDate
--take the result calculated above into a variable
declare @ActualDate date --could use datetime if desired
set @ActualDate = DATEADD(day,@JulianDate%1000-1,CAST(cast(@JulianDate/1000 + 1900 as varchar(4)) + '-01-01' as date))
--format it however you fancy (see http://www.w3schools.com/sql/func_convert.asp)
select CONVERT(nvarchar(24), @ActualDate, 113)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment