MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

YYDDD date math in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
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

PostPosted: Sat Jul 22, 2006 1:42 pm    Post subject: YYDDD date math in COBOL Reply with quote

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
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jul 22, 2006 4:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Pudah
Beginner


Joined: 20 Jun 2003
Posts: 27
Topics: 8
Location: East of the Rock, West of the Hard Place

PostPosted: Mon Jul 24, 2006 8:13 am    Post subject: Reply with quote

Thanks Kolusu, I don't know how I missed that post in my search.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group