View previous topic :: View next topic
|
Author |
Message |
Direction
New User
Joined: 15 Sep 2005 Posts: 11
|
|
|
|
HI all,
Need ur help. I want to subtract 10 days from the date which is in the YYYYMMDD format.
For example if 20060403 is the data than after subtracting 10 it should be
20060323. OR if date is 20060102 than after subtracting it should be 20051222.
Is there is any function for it.
It would be great if u give me some link to perform these type of arithmetic operation on date.
Thanx |
|
Back to top |
|
|
amitrath
New User
Joined: 30 Apr 2004 Posts: 28 Location: Carmel, USA.
|
|
|
|
I have done this by using a 3 step procedure:
Convert the YYMMDD date to Days-of-century (nbr of days starting from century) format Substract 10 from days-of-century format Convert the resul back to YYMMDD format |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
Back to top |
|
|
amitrath
New User
Joined: 30 Apr 2004 Posts: 28 Location: Carmel, USA.
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
This should work:
Code: |
05 INT-DAYS PIC S9(008) COMP.
05 NEW-CYMD PIC 9(008).
COMPUTE INT-DAYS = (INTEGER-OF-DATE(YOUR-CYMD) - 10)
COMPUTE NEW-CYMD = (DATE-OF-INTEGER(INT-DAYS)
DISPLAY 'OLD DATE ' YOUR-CYMD
DISPLAY 'NEW DATE ' NEW-CYMD
|
|
|
Back to top |
|
|
|