Tag Archives: Julian

How to convert EnterpriseOne (JDE) Julian Dates


If you’ve ever worked with Oracle/PeopleSoft’s EnterpriseOne ERP system (also known as JD Edwards or simply JDE) you’ll quickly find that dealing with dates from the database is a bit challenging.  EnterpriseOne stores all dates in the system in Julian Date format.  EnterpriseOne has a lot of dates in every table.

The Julian Date in EnterpriseOne goes back to the days before EnterpriseOne was called EnterpriseOne; back when it was just JD Edwards and it ran on an AS/400 (now called an iSeries or Series i).  Back then, disk space (DASD) was a premium.  By storing all the dates in 6-digit Julian format, the numbers could be packed (compressed) to save table or database space.  Additionally, since Julian Dates are in a fairly simple numerical form, it was easy to develop routines and functions to add, subtract, and otherwise calculate dates.

Over the years, disk space has turned into a commodity.  Modern computer languages and SQL  can easily deal with date calculation.  But EnterpriseOne data is still in this Julian Date format.   So how do we deal with it, and how do we get it converted into a normal datetime data type?

This article will cover how to create and use two SQL functions to convert Julian dates to Gregorian dates and then to convert Gregorian dates to EnterpriseOne Julian format.  Many of my clients use these two functions for SQL Server Reporting Services (SSRS) Reports, and various EDI interfaces, and XML feeds.  These two functions are valid on any version of JD Edwards including World, OneWorld, XE, or the latest version of EnterpriseOne.  If you want to use the functions on World, or directly on an IBM Series i, you’ll need to do a bit of syntax tweaking.  If you’re accessing the Series i (AS/400) from SQL Server, then this function will work perfectly for you.

EnterpriseOne Julian format

All versions of JDE use a Julian Date format as follows: CYYDDD where C = Century; YY = a 2 digit year; and DD = the 3 digit number representing the day of the year (1 through 365 or 366 days on a leap year).  The Century is either a 1 or 0 depending on whether you’re using year 2000 + or if you’re using dates in the 1900’s.

For example, the Gregorian Date 01/01/2009 would be Julian Date 109001 where 1 = century 2000, 09 = the last 2 digits of the year 2009; and 001 = the first day in 2009. Similarly 12/31/2009 would be represented as 109365 where the only change is the day number being 365 to represent the last day in 2009.

Note: A value of zero(0) in JDE Julian date format represents 12/31/1899 and 01/01/1900 is the numerical value 1 in Julian format.

Converting Julian Dates to Gregorian – Date J2G( )

The first function we’re going to write is one called DateJ2G() meaning “Date Julian to Gregorian”. This function has two parameters, one parm for the Julian date you wish to convert, and one parm for the format style code, which represents the format you want your Gregorian date.  The DateJ2G() function will convert the date to any standard SQL Server formatted date style.  A complete list of format styles can be found at

Here’s the code to create the function:


RETURNS varchar(20) AS  
--Written by Bryant Avey, InterNuntius, Inc.
--Provided free "As Is" with no warranties or guarantees
--I just ask that you keep these comments in the function, if you use it.
--The complete article describing this function can be found at:

--This function takes a JDE Julian Date and returns
--a varchar date in the format style you specify
--To us simply pass in the JDE date and the style code
--Style codes can be found at 

--For Example: select dbo.DateJ2G(sddgj,101) from f4211
--would return the JDE date in the format of 02/29/2008.
--Select dbo.DateJ2G(108060, 1) = 02/29/08
--Select dbo.DateJ2G(109060, 107) = Mar 01, 2009

--Format codes are standard SQL 2005 Date Convert codes.
--Conversion codes can be found here:
DECLARE @sqldate datetime
set @sqldate =
 dateadd(day,cast((1900000 + @JDEDATE)%1000 as int)-1,(cast((
 cast((1900000 + @JDEDATE)/1000 as varchar(4)) + '-01-01')
 as datetime)))

RETURN (convert(varchar(20),@sqldate,@FORMAT))

To use the DateJ2G function, just pass in a date and style format as described in the comments contained in the above code.

Converting Gregorian Dates to Julian – DateG2J( )

The next function will convert any standard formatted Gregorian date string to a JDE EnterpriseOne Julian date.

Here’s the code to create the DateG2J function:

CREATE FUNCTION [dbo].[DateG2J] (@Geogian_in datetime)
--Written by Bryant Avey, InterNuntius, Inc.
--Provided free "As Is" with no warranties or guarantees
--I just ask that you keep these comments in the function, if you use it.
--The complete article describing this function can be found at:

--This function takes a varchar gregorian date and returns
--a Julian JDE Date
--To use simply pass in the string date

--For Example: select dbo.DateG2J('02/29/2008')
--would return the JDE integer date of 108060.

--Date input formats are standard SQL 2005 DateTime values.
--Any validly formated date string will work such as 'feb 29,2008' to get 108060.

declare @JulianDate_out INT
declare @Century INT
declare @YY INT
declare @DayofYear INT

 Select @Century = case when datepart(yyyy,@Geogian_in) > 2000
 then 100000 else 0 end

 AS VARCHAR(4)), 3, 2)) AS INT)

 select @DayOfYear = datepart(dayofyear, @Geogian_in)

 SELECT @JulianDate_out = @Century + @YY * 1000 + @DayofYear


To use the DateG2J function just follow the examples outlined in the code above.


As you can see, there are only a few lines of SQL code needed to convert between Julian and Gregorian dates in JDE EnterpriseOne.  I used February 29, 2008 (leap year) dates in the examples to show that the functions correctly handle leap years.

Let me know how this has worked for you.


Posted by on August 16, 2009 in TechKnowledgy Articles


Tags: , , , , , , , , , , , , , ,


a blog by Bryant Avey

Bamboo Innovator

R.E.S.-ilience in Value Creation 《竹经:经商经世离不得立根创新》

On Purpose Magazine

Inspiring, Educational, Enlightening and Entertaining Content of Value


The real-time, continuous word tournament!

Ricky's Bing Maps Blog

A blog focused on developing applications with Bing Maps

a blog by Bryant Avey

JJ's Blog

Microsoft Business Intelligence and SharePoint in Action

SQL Server Rider

Database, SSIS, SSAS, SSRS, PowerPivot, GIS

Nishant Rana's Weblog

Everything related to Microsoft Technology


SharePoint, ProjectServer and Microsoft Platform

Connection Agent

What do you need? Ask Steve!

Choiceology Blog

Just another weblog

Tales from the IT Side

Understanding SharePoint and how it interacts with your organization

Reckless Abandon

...with all your heart, soul, mind, and strength


Serving up the hottest dishes on

Clayton's SharePoint Madness

All About SharePoint, InfoPath, and SharePoint Designer!

...focusing on the evolution and economics of high technology business and strategy. By day, I am a venture capitalist at Benchmark Capital.


Get every new post delivered to your Inbox.

Join 1,777 other followers

%d bloggers like this: