View previous topic :: View next topic
|
Author |
Message |
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
sjiraga
New User
Joined: 20 Apr 2009 Posts: 14 Location: Bangalore
|
|
|
|
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 |
|
|
sjiraga
New User
Joined: 20 Apr 2009 Posts: 14 Location: Bangalore
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
ram2010
New User
Joined: 24 Mar 2010 Posts: 1 Location: Chennai
|
|
|
|
You are correct |
|
Back to top |
|
|
sjiraga
New User
Joined: 20 Apr 2009 Posts: 14 Location: Bangalore
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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...
Where is calculation done for getting previous day ???? |
|
Back to top |
|
|
sjiraga
New User
Joined: 20 Apr 2009 Posts: 14 Location: Bangalore
|
|
|
|
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 |
|
|
|