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
 

 

fetch previous date ( current date - 1)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 436
Location: chennai, India

PostPosted: Thu Mar 18, 2010 9:12 am    Post subject: fetch previous date ( current date - 1)
Reply with quote

I am trying to fetch previous date in COBOL through CURRENT DATE function - 1 DAY. I don't get the logic or the parameter correct to get the desired result. Can any one please tell me the short code/logic how to go ahead with the function to fetch previous date in COBOL. I am not using DB2 here.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8054
Location: East Dubuque, Illinois, USA

PostPosted: Thu Mar 18, 2010 9:17 am    Post subject:
Reply with quote

There is a link to manuals at the top of the page. Click it, click on the COBOL Language Reference manual, and look up the INTEGER-OF-DATE and DATE-OF-INTEGER intrinsic functions in chapter 7.1. These functions simplify date calculations.
Back to top
View user's profile Send private message
sjiraga

New User


Joined: 20 Apr 2009
Posts: 13
Location: Bangalore

PostPosted: Mon Mar 22, 2010 3:34 pm    Post subject: Reply to: fetch previous date ( current date - 1)
Reply with quote

we dont have option to fetch the previous date but we can do the computation to get the same.

You need to first get the current date and you need to convert it into the julian date and then with help of computation substract one from the julian date i.e. already you have saved.

I hope this helps you....
Back to top
View user's profile Send private message
sjiraga

New User


Joined: 20 Apr 2009
Posts: 13
Location: Bangalore

PostPosted: Mon Mar 22, 2010 4:55 pm    Post subject: Reply to: fetch previous date ( current date - 1)
Reply with quote

MOVE FUNCTION CURRENT-DATE(1:8) TO WS-CURRENT-DATE.
COMPUTE WS-INTEGER-DATE =
FUNCTION INTEGER-OF-DATE(WS-CURRENT-DATE).

Display 'Previous Date = ' WS-INTEGER-DATE
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Mar 22, 2010 5:01 pm    Post subject: Re: Reply to: fetch previous date ( current date - 1)
Reply with quote

sjiraga wrote:
MOVE FUNCTION CURRENT-DATE(1:8) TO WS-CURRENT-DATE.
COMPUTE WS-INTEGER-DATE =
FUNCTION INTEGER-OF-DATE(WS-CURRENT-DATE).

Display 'Previous Date = ' WS-INTEGER-DATE


I would suggest you test this before posting it!
Back to top
View user's profile Send private message
ram2010

New User


Joined: 24 Mar 2010
Posts: 1
Location: Chennai

PostPosted: Wed Mar 24, 2010 2:51 pm    Post subject: Yes
Reply with quote

You are correct icon_rolleyes.gif
Back to top
View user's profile Send private message
sjiraga

New User


Joined: 20 Apr 2009
Posts: 13
Location: Bangalore

PostPosted: Wed Mar 24, 2010 2:57 pm    Post subject: Reply to: fetch previous date ( current date - 1)
Reply with quote

Before posting I have tested in my system and it is working fine and let me know if you have any questions
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Mar 24, 2010 3:14 pm    Post subject: Re: Reply to: fetch previous date ( current date - 1)
Reply with quote

sjiraga wrote:
Before posting I have tested in my system and it is working fine and let me know if you have any questions


Do not test just for syntax errors
Also check if it satisfies OP's requirement too... icon_wink.gif

Where is calculation done for getting previous day ???? icon_question.gif icon_question.gif
Back to top
View user's profile Send private message
sjiraga

New User


Joined: 20 Apr 2009
Posts: 13
Location: Bangalore

PostPosted: Wed Mar 24, 2010 3:31 pm    Post subject: Reply to: fetch previous date ( current date - 1)
Reply with quote

MOVE FUNCTION CURRENT-DATE(1:8) TO WS-CURRENT-DATE.
COMPUTE WS-INTEGER-DATE =
FUNCTION INTEGER-OF-DATE(WS-CURRENT-DATE) - 1.
MOVE FUNCTION DATE-OF-INTEGER(WS-INTEGER-DATE TO WS-PREV-DATE.

Display 'Previous Date = ' WS-PREV-DATE

The above one will give the previous date
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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm


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