View previous topic :: View next topic
|
Author |
Message |
purushoth_jp
New User
Joined: 12 Dec 2004 Posts: 22
|
|
|
|
Hi all,
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. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
There is a DATE built in finction, with some options. You can manipulate dates. Please refer to the fine manual.
O. |
|
Back to top |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
You can display date functions in REXX by doing:
Code: |
DATE1 = DATE('B')
SAY DATE1
DATE2 = DATE('D')
SAY DATE2
DATE3 = DATE('E')
SAY DATE3
|
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:
Code: |
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. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 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. |
|
Back to top |
|
|
purushoth_jp
New User
Joined: 12 Dec 2004 Posts: 22
|
|
|
|
Thanks for your reply. i tried its working.. thanks |
|
Back to top |
|
|
|