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: 7932
Location: Bellevue, IA

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: 11
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: 11
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: 11
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: 11
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 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