I'm new to REXX, I want to know is there is any inbuilt date functions for date manipulations. If it is please let me know.
My requirement is to subtract 3 months from the current date and to display the result
ex.. if current date is 21-02-2007. then the result should be 21-12-2006.
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
You can display date functions in REXX by doing:
DATE1 = DATE('B')
DATE2 = DATE('D')
DATE3 = DATE('E')
Other date options are M, N, O, S, U, and W. Doing this will allow you to see the various formats of the dates. For example, DATE('E') is the european date and will look like 31/12/06.
The BASE date shown as DATE('B') is the numeric base date. You can convert any of the other dates to the base date (subtract 90 for 3 months) and convert the base date back to the original date.
This is done by:
CURRDT = DATE('E')
/* CONVERT EUROPEAN DATE DD/MM/YY TO BASE (NUMERIC DATE) */
CURRBDTE = DATE('BASE',CURRDT,'EUROPEAN')
CURRBDTE = CURRBDTE - 90
/* CONVERT BASE DATE BACK TO EUROPEAN DATE */
NWCURRDT = DATE('EUROPEAN',CURRBDTE,'BASE')
You can also build your own date variables from your input. Just ensure they look exactly like the date function expects them to look (i.e. DD/MM/YY for european, 31 DEC 2006 for normal). They can then be converted to the base (numeric date), manipulated (like subtracting 90), and then converted back.
Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
I've also found, through the years, that any existing in-house written date calculation routines, when properly written, typically work as well in a REXX program as they do in a COBOL or other language program.