2008-09-15

J.D. Edwards date hack

J.D. Edwards store dates on i5/OS as CYYDDD, where C is 0 for the 20th Century and 1 for the 21st, YY is the year within that century and DDD is the day within that year, so '072041' is 10th February 1972. The DB2 database engine on i5/OS provides support for a number of date formats, none of which is CYYDDD, so I came up with the following to convert them to YYYYDDD, which DB2's DATE function recognises and treats appropriately:


   DATE(
      CASE
         WHEN LEFT('072041',1) = '0' THEN '19'
         WHEN LEFT('072041',1) = '1' THEN '20'
      END ||
      RIGHT('072041',5)
   )

Substitute a string or field in J.D. Edwards' date format for '072041'.

0 comments: