(z/OS, all versions) USEFUL CODE: REXX ISO and DB2 dates

Philip Sevetson

(z/OS, all versions) USEFUL CODE: REXX ISO and DB2 dates
Hello, all DB2-and-REXX Users! I realize that this is somewhat stretching
the list's definition, but I'm sure there are interested users out there.

Here's an interesting set of useful REXX statements from my
comrade-in-programming, Tom Raskin.

Consider the standard REXX formats and notice that they don't include ISO
(CCYY-MM-DD) or extended USA (MM/DD/CCYY) date formats, both of which are
DB2 standard date display formats. (I'm referring to this as 'extended
USA format' to distinguish it from what REXX considers to be the 'USA
format', MM/DD/YY.)

Now try the code below with your REXX processor; see how much easier it
makes DB2 date processing with REXX?

*************************

Phil,
Try this out .... the YEARMNDT method is not documented in our z/OS
manuals but is in z/VM I think ...

/* Rexx */
/* Any date format to ISO */
myDate = "12/11/04";
say "Date in original (USA) format is:" myDate;
say "Date in new (ISO) format is:",
translate('YEAR-MN-DT',Date('S',myDate,'U'),'YEARMNDT')

/* ISO to any date format */
myDate = "2004-10-11";
say "Date in original (ISO) format is:" myDate;
say "Date in new (USA) format is:",
date('U',translate('YEARMNDT',myDate,'YEAR-MN-DT'),'S')
return;

**************************

and my own modification of the ISO conversion, here...

/* REXX */
/* ANY DATE FORMAT TO EXT USA */
MYDATE = "12/11/04";
SAY "DATE IN ORIGINAL (USA) FORMAT IS:" MYDATE;
SAY "DATE IN NEW (EXT USA) FORMAT IS:",
TRANSLATE('MN/DT/YEAR',DATE('S',MYDATE,'U'),'YEARMNDT')

/* EXT USA TO ANY DATE FORMAT */
MYDATE = "10/11/2004";
SAY "DATE IN ORIGINAL (EXT USA) FORMAT IS:" MYDATE;
SAY "DATE IN NEW (USA) FORMAT IS:",
DATE('U',TRANSLATE('YEARMNDT',MYDATE,'MN/DT/YEAR'),'S')
RETURN;

--Phil Sevetson
Database Administration
Wakefern Food Corporation CISD
230 Raritan Center Parkway, P5-105
Edison, NJ 08837
Phone: (732) 225-8086
Fax: (732) 225-8109
mailto:[login to unmask email]


---------------------------------------------------------------------------------
Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page select "Join or Leave the list". The IDUG DB2-L FAQ is at http://www.idugdb2-l.org. The IDUG List Admins can be reached at [login to unmask email] Find out the latest on IDUG conferences at http://conferences.idug.org/index.cfm