View previous topic :: View next topic
|
Author |
Message |
raj_mainframe08
New User
Joined: 11 Sep 2007 Posts: 65 Location: Gurgaon
|
|
|
|
is there any function in COBOL which helps me toget the previous date.
For Example
If today the date is 01/01/2009, it will give me 31/12/2008. Or whatever date is there, i need to have the previous date? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
integer-of-date and date-of integer will satisfy Your needs
workdate = integer-of-date(some-date)
workdate = workdate - 1
prevdate = date-of-integer(workdate)
I refuse to speak COBOLESE but the logic should be clear enough
also search the forums to get additional info |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Code: |
COMPUTE DATE-INTEGER =
FUNCTION INTEGER-OF-DATE (DATE-VALUE) .
SUBTRACT 1 FROM DATE-INTEGER.
COMPUTE YESTERDAY-VALUE =
FUNCTION DATE-OF-INTEGER (DATE-INTEGER) .
DISPLAY 'CURRENT DATE ' DATE-VALUE.
DISPLAY 'INTEGER ' DATE-INTEGER.
DISPLAY 'YESTERDAY DATE ' YESTERDAY-VALUE. |
produces as output
Code: |
CURRENT DATE 20090101
INTEGER 00149019
YESTERDAY DATE 20081231 |
where all 3 fields are PIC 9(08). |
|
Back to top |
|
|
|