How do I change a Julian date to a Gregorian date and remain Y2K compliant?
I am not sure how the year is stored in the Julian date, so I will suppose that it is at the beginning of the Julian string for the sake of this solution. I will also assume that the Julian date is stored as a character value.
Let’s assume there is a Julian date 1999003, which would be Jan 3, 1999. Create a PRG file with the following code in it:
?ConvertJulianToDate("1999003") PROCEDURE ConvertJulianToDateLPARAMETERS tcJulianDateLOCAL lcJulianYear,lcJulianNumberLOCAL lnJulianNumber, ldReturnValuelcJulianYear = LEFTC(tcJulianDate,4)lcJulianDay = RIGHTC(tcJulianDate,3)lnJulianDay = VAL(lcJulianDay)*-- Create a date that is Jan 1st of Julian yearldReturnValue = CTOD("01/01/"+lcJulianYear)*-- Add the numeric Julian date and subtract*-- one because Jan 1 = 1, not zeroldReturnValue = ldReturnValue + lnJulianDay - 1RETURN ldReturnValueENDPROC