View previous topic :: View next topic |
Author |
Message |
Pudah Beginner
Joined: 20 Jun 2003 Posts: 27 Topics: 8 Location: East of the Rock, West of the Hard Place
|
Posted: Sat Jul 22, 2006 1:42 pm Post subject: YYDDD date math in COBOL |
|
|
Maybe I'm using the wrong terms, but I've been searching the forum and I haven't been able to find any threads to help with what I am trying to do.
I've got an iput record that contains a date in YYDDD format. The input record also contains an adjustment factor by which the date needs to be modified. I need to subtract the adjustment factor from the date to get an adjusted date, also in YYDDD format.
For example, the date is 06203. If the adjustment is 2, the result should be 06201. If the date is 07003 and the adjustment factor is 3, the result should be 06365.
This seems simple enough, but I can't figure it out. Can any of you give me a suggestion on how to do this in a COBOL program (hopefully with built in date functions)? Any help would be greatly appreciated. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Sat Jul 22, 2006 4:59 pm Post subject: |
|
|
Pudah,
Check this link
http://www.mvsforums.com/helpboards/viewtopic.php?p=10911#10911
It shows the date calculations on gregorian format. you need to change them to
Code: |
01 WS-IN-JUL-DATE PIC 9(07).
01 WS-OUT-JUL-DATE PIC 9(07).
COMPUTE WS-OUT-JUL-DATE = FUNCTION DAY-OF-INTEGER
(FUNCTION INTEGER-OF-DAY(WS-IN-JUL-DATE) + WS-ADD-DAYS)
COMPUTE WS-OUT-JUL-DATE = FUNCTION DAY-OF-INTEGER
(FUNCTION INTEGER-OF-DAY(WS-IN-JUL-DATE) - WS-SUB-DAYS)
|
Your input date is only 5 bytes without century portion. you can either hard code the century portion as 20 or use another intrinsic function FUNCTION YEAR-TO-YYYY to convert the 2 digit year to 4 digit year. Check this link which explains in detail about the instrinsic funtions.
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/7.1?DT=20020920180651
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Pudah Beginner
Joined: 20 Jun 2003 Posts: 27 Topics: 8 Location: East of the Rock, West of the Hard Place
|
Posted: Mon Jul 24, 2006 8:13 am Post subject: |
|
|
Thanks Kolusu, I don't know how I missed that post in my search. |
|
Back to top |
|
 |
|
|