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

fetch previous date ( current date - 1)


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

Active User


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

PostPosted: Thu Mar 18, 2010 9:12 am
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 18, 2010 9:17 am
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: 14
Location: Bangalore

PostPosted: Mon Mar 22, 2010 3:34 pm
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: 14
Location: Bangalore

PostPosted: Mon Mar 22, 2010 4:55 pm
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
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
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: 14
Location: Bangalore

PostPosted: Wed Mar 24, 2010 2:57 pm
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
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: 14
Location: Bangalore

PostPosted: Wed Mar 24, 2010 3:31 pm
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 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