How JD Edwards Julian dates work
JD Edwards stores dates as a number in the form CYYDDD. It is not the astronomical Julian day number.
- C is the century: 0 for the 1900s, 1 for the 2000s.
- YY is the two-digit year.
- DDD is the day of the year, from 001 to 365 (366 in a leap year).
So 126335 is century 1, year 26, day 335: December 1, 2026. Dates in the 1900s usually appear as five digits, because the leading zero is dropped: 99365 is December 31, 1999. A value of 0 means the date is blank.
The short formula is (year − 1900) × 1000 + day of year.
Converting in SQL
Replace jdedate with your column name. Filter out zero (blank) dates first, and check the results against your own data.
SQL Server
-- JDE to date
DATEADD(day, CAST(jdedate AS int) % 1000 - 1,
DATEFROMPARTS(1900 + CAST(jdedate AS int) / 1000, 1, 1))
-- date to JDE
(YEAR(mydate) - 1900) * 1000 + DATEPART(dayofyear, mydate)
Oracle Database
-- JDE to date
TO_DATE(TO_CHAR(jdedate + 1900000), 'YYYYDDD')
-- date to JDE
TO_NUMBER(TO_CHAR(mydate, 'YYYYDDD')) - 1900000
IBM i (Db2)
-- JDE to date
DATE(DIGITS(DECIMAL(jdedate + 1900000, 7, 0)))
-- date to JDE
(YEAR(mydate) - 1900) * 1000 + DAYOFYEAR(mydate)