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
 

 

Manipulate date variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Manipulate date variable
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    Post subject:
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    Post subject: Reply to: Manipulate date variable
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    Post subject: Reply to: Manipulate date variable
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    Post subject:
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    Post subject: Reply to: Manipulate date variable
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    Post subject:
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    Post subject: Reply to: Manipulate date variable
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    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Thu May 08, 2008 1:04 pm    Post subject:
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu May 08, 2008 4:42 pm    Post subject: COBOL Version/Release?
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    Post subject:
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    Post subject: Manipulate date variable
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    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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us