Converting JD Edwards dates to standard dates

Oracle’s JD Edwards ERP system stores dates in a custom variant of a Julian date format as described at
https://docs.oracle.com/cd/E26228_01/do … m#WEAWX259. While Clover does not have a built-in function to convert a JD Edwards date to a standard date , one can easily be written in CTL2.

function date jdedate2date(decimal jdeDate) {

    string jdeString = num2str(decimal2integer(jdeDate));
    // calculate year component of date
    date standardDate = createDate(1900+((decimal2integer(jdeDate))/1000),1,1);
    // calculate day of year component of date
    integer days = str2integer(substring(jdeString, length(jdeString)-3))-1;
    // create standard date by adding days to year
    standardDate = dateAdd(standardDate, days, day);

    return standardDate;
}