Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search 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 -> Mainframe COBOL
Author Message
srvk_2k2

New User


Joined: 07 May 2008
Posts: 17
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
References
PostPosted: Thu May 08, 2008 9:39 am    Post subject: Re: Manipulate date variable Reply with quote

the_gautam

Active User


Joined: 05 Jun 2005
Posts: 169
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: 17
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: 17
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: 169
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: 17
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: 169
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: 17
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: 169
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

Senior Member


Joined: 20 Oct 2006
Posts: 1368
Location: germany

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

Senior Member


Joined: 13 Feb 2004
Posts: 309
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

Active User


Joined: 14 Jan 2008
Posts: 262
Location: Orlando, FL, 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: 17
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: 17
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1