View previous topic :: View next topic
|
Author |
Message |
srvk_2k2
New User
Joined: 07 May 2008 Posts: 36 Location: Chennai
|
|
|
|
Hi,
How to manipulate with dates...
My requirement is to get the previous date from system date in COBOL
What are all the possible and easy ways?
Thanks in Advance
Saravana |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
arent you using DB2 in your program? |
|
Back to top |
|
|
srvk_2k2
New User
Joined: 07 May 2008 Posts: 36 Location: Chennai
|
|
|
|
No Yaar..It's simple COBOL program
Regards,
Saravana S |
|
Back to top |
|
|
srvk_2k2
New User
Joined: 07 May 2008 Posts: 36 Location: Chennai
|
|
|
|
I have tried with the function 'SUBTRACT-DURATION
'. But it's not working.I think it's for some other version of COBOL.I'm not sure.
Regards,
Saravana S |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
after accepting the date from the system, you are storing that in a WORKING-STORAGE variable.
so, why cant you simply subtract 1 from the date part to get the previous date?
ofcourse, you need to take care of the month and year values if the current date is the first day of a month/year. |
|
Back to top |
|
|
srvk_2k2
New User
Joined: 07 May 2008 Posts: 36 Location: Chennai
|
|
|
|
Thanks for your reply Gautam.Is there any other way/in-built fuction to simply get the previous date. If so it would be helpful
Regards,
Saravana S |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
not sure. i used a program to calculate the date difference / date validation and now whenever i need this logic, i use to call that program. |
|
Back to top |
|
|
srvk_2k2
New User
Joined: 07 May 2008 Posts: 36 Location: Chennai
|
|
|
|
Can you post that?
Regards,
Saravana S |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
sorry, i am not supposed to publish the company assets. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Saravana,
almost every shop has some kind of date routine/service. I would ask your peers/systems people. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Hi Saravana,
try this ...
Code: |
01 YYYYMMDD Pic 9(8).
01 date-to-Integer Pic S9(9).
Move Function Current-Date(1:8) to YYYYMMDD
Compute date-to-Integer = Function Integer-of-Date(YYYYMMDD)
Subtract 1 from date-to-Integer
Compute YYYYMMDD = Function Date-of-Integer(date-to-Integer)
|
this will give you the previous date in numeric format ...
try this ..i have not tested this ... and let us know ...
thanks,
ashimer |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
What is your version/release of COBOL?
The minimum is COBOL/370 (released over 15 years ago) for the support of FUNCTION's, which is the successor to COBOL2.
FUNCTION SUBTRACT-DURATION is not a valid COBOL FUNCTION, regardless of the COBOL version/release.
When you say you need the "previous system-date", what is the amount of time do you need to subtract from the current-date? Minutes, Hours, Days, etc? We're all unsure.
To use the supported COBOL FUNCTION's, check out -
01) FUNCTION CURRENT-DATE
02) FUNCTION INTEGER-OF-DATE
03) ADJUST RESULT FROM INTEGER-OF-DATE
04) FUNCTION DATE-OF-INTEGER
However, I second Dick's suggestion regarding a standardized date methodology sub-system and you should speak with some of your other colleagues.
Regards,
Bill |
|
Back to top |
|
|
srvk_2k2
New User
Joined: 07 May 2008 Posts: 36 Location: Chennai
|
|
|
|
Yes ashimer. Your suggestion worked...Thanks a lot
Regards,
Saravana S |
|
Back to top |
|
|
srvk_2k2
New User
Joined: 07 May 2008 Posts: 36 Location: Chennai
|
|
|
|
Finally it worked....thanks all for the replies
Regards,
Saravana S |
|
Back to top |
|
|
|