Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Previous date then the current date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Previous date then the current date
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Thu Jan 08, 2009 6:22 pm    Post subject: Reply to: Previous date then the current date
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: 7931
Location: Bellevue, IA

PostPosted: Thu Jan 08, 2009 6:27 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us