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

Manipulate date variable


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

New User


Joined: 07 May 2008
Posts: 36
Location: Chennai

PostPosted: Thu May 08, 2008 9:39 am
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu May 08, 2008 9:49 am
Reply with quote

arent you using DB2 in your program?
Back to top
View user's profile Send private message
srvk_2k2

New User


Joined: 07 May 2008
Posts: 36
Location: Chennai

PostPosted: Thu May 08, 2008 9:53 am
Reply with quote

No Yaar..It's simple COBOL program

Regards,
Saravana S
Back to top
View user's profile Send private message
srvk_2k2

New User


Joined: 07 May 2008
Posts: 36
Location: Chennai

PostPosted: Thu May 08, 2008 9:57 am
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu May 08, 2008 9:58 am
Reply with quote

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
View user's profile Send private message
srvk_2k2

New User


Joined: 07 May 2008
Posts: 36
Location: Chennai

PostPosted: Thu May 08, 2008 10:00 am
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu May 08, 2008 10:06 am
Reply with quote

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
View user's profile Send private message
srvk_2k2

New User


Joined: 07 May 2008
Posts: 36
Location: Chennai

PostPosted: Thu May 08, 2008 10:15 am
Reply with quote

Can you post that?

Regards,
Saravana S
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu May 08, 2008 10:23 am
Reply with quote

sorry, i am not supposed to publish the company assets.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 08, 2008 1:04 pm
Reply with quote

Saravana,

almost every shop has some kind of date routine/service. I would ask your peers/systems people.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu May 08, 2008 4:38 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu May 08, 2008 4:42 pm
Reply with quote

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
View user's profile Send private message
srvk_2k2

New User


Joined: 07 May 2008
Posts: 36
Location: Chennai

PostPosted: Thu May 29, 2008 11:39 am
Reply with quote

Yes ashimer. Your suggestion worked...Thanks a lot

Regards,
Saravana S
Back to top
View user's profile Send private message
srvk_2k2

New User


Joined: 07 May 2008
Posts: 36
Location: Chennai

PostPosted: Thu May 29, 2008 11:41 am
Reply with quote

Finally it worked....thanks all for the replies

Regards,
Saravana S
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top