IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Previous date then the current date


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raj_mainframe08

New User


Joined: 11 Sep 2007
Posts: 65
Location: Gurgaon

PostPosted: Thu Jan 08, 2009 6:11 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jan 08, 2009 6:22 pm
Reply with quote

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 icon_biggrin.gif but the logic should be clear enough

also search the forums to get additional info
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 08, 2009 6:27 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Changeman - how can we know the curr... Compuware & Other Tools 2
Search our Forums:

Back to Top