Created
January 25, 2014 13:29
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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