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
 

 

Equivalent for FUNCTION ADD-DURATION in COBOL 370

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
deepag02

New User


Joined: 23 Jul 2007
Posts: 20
Location: India

PostPosted: Fri Nov 21, 2008 12:39 pm    Post subject: Equivalent for FUNCTION ADD-DURATION in COBOL 370
Reply with quote

hey guys,
Is there an equivalent for FUNCTION ADD-DURATION in COBOL 370?
i have a requiremnt to add months to a date field pic X(10) .
for example if
ws-date = 2008-01-30
I need a function to add + 1 month to give me 2008-02-28.
Note : the date need not always be the last day of a month.

Thanks
Back to top
View user's profile Send private message

deepag02

New User


Joined: 23 Jul 2007
Posts: 20
Location: India

PostPosted: Fri Nov 21, 2008 12:57 pm    Post subject:
Reply with quote

If the date is january 30th , plus 1 month should give me feb 28th.

I came across this function move FUNCTION ADD-DURATION(W-curdate1 MONTHS 1)
to w-futurdate1.
display w-curdate1 " + 1 months is "
w-futurdate1. Same function can also be used to add days / years etc .

But this function was not working with cobol 370. I think it was part of an older version of cobol.

Thanks
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Nov 21, 2008 2:15 pm    Post subject:
Reply with quote

Hi Deepang,You can use below functions to achieve required.
FUNCTION INTEGER-OF-DATE
FUNCTION DATE-OF-INTEGER

Here are some examples which manipulates date using above functions
http://www.ibmmainframes.com/viewtopic.php?t=30525&highlight=integerofdate
http://www.ibmmainframes.com/viewtopic.php?t=33741&highlight=integerofdate
http://www.ibmmainframes.com/viewtopic.php?t=34255&highlight=integerofdate
Back to top
View user's profile Send private message
deepag02

New User


Joined: 23 Jul 2007
Posts: 20
Location: India

PostPosted: Fri Nov 21, 2008 2:25 pm    Post subject:
Reply with quote

Thanks Sambhaji for the response. But the INTEGER-OF-DATE and DATE-OF-INTEGER functions are helpful only if we know the exact integer value to be added or subtracted from a date field.
I am looking for some function in cobol which would do the same as in SQL query :

EXEC SQL
Update table
set end_date = end_date + 1 month
where
.......
END-EXEC

Thanks in advance[color=darkblue]
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Nov 21, 2008 2:46 pm    Post subject:
Reply with quote

Quote:
But the INTEGER-OF-DATE and DATE-OF-INTEGER functions are helpful only if we know the exact integer value to be added or subtracted from a date field.

Yes ofcourse. Dont you have it?
What do you mean by one month then?
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Fri Nov 21, 2008 2:48 pm    Post subject:
Reply with quote

deepag02,

You can use this in COBOL also, It is also called Intrinsic Function(Built in Function).

For Further details find link below

http://www.cse.ohio-state.edu/~sgomori/314/intrinsic.html
Back to top
View user's profile Send private message
deepag02

New User


Joined: 23 Jul 2007
Posts: 20
Location: India

PostPosted: Fri Nov 21, 2008 3:36 pm    Post subject:
Reply with quote

The problem is 1 month can be 30 days or 31 days or even 28/29 days. Now if my client sets his frequency as monthly and the current date is jan 1st, I need to update the date to feb 1st and then march 1st. If I use INTERGER-OF-DATE and DATE-OF-INTEGER function I would be adding 30 days or so every time. In that case first it will be jan 1st + 30 =
Back to top
View user's profile Send private message
deepag02

New User


Joined: 23 Jul 2007
Posts: 20
Location: India

PostPosted: Fri Nov 21, 2008 3:40 pm    Post subject:
Reply with quote

PLS ignore the previous post.

The problem is 1 month can be 30 days or 31 days or even 28/29 days. Now if my client sets his frequency as monthly and the current date is jan 1st, I need to update the date to feb 1st and then march 1st. If I use INTERGER-OF-DATE and DATE-OF-INTEGER function I would be adding 30 days or so every time. In that case first it will be jan 1st + 30 = feb 1st. then feb 1st + 30 days = march 2nd. This is in correct.

The frequency set by my client can also be bi monthly, half yearly etc icon_smile.gif
So was looking for a built in function which can handle all these conditons..
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri Nov 21, 2008 3:41 pm    Post subject:
Reply with quote

Usually the sites have some 'homegrown' routines to handle date manipulations. See if you have one in your system. Best people to inquire will be your peers.
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: Fri Nov 21, 2008 4:56 pm    Post subject: Re: DATE ADDITION
Reply with quote

Review the following LINK, as it's similar to your post -

http://ibmmainframes.com/viewtopic.php?t=36040

Regards,

Bill
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Nov 21, 2008 7:20 pm    Post subject:
Reply with quote

Hi Deepag,

The terms you're using (monthly, bi-monthly, half yearly) can have a variety of meanings.

Provide us w/examples of each (showing the normal occurance AND the exceptions, e.g. 1/1/08 + 1 mo = 2/1/08, BUT 1/31/08 + 1 mo = 2/29/08 or 2/28 if not leap year, etc.).
Back to top
View user's profile Send private message
Antonio Barata
Warnings : 1

New User


Joined: 04 Apr 2007
Posts: 37
Location: Lisbon, Portugal

PostPosted: Tue Nov 25, 2008 2:59 pm    Post subject:
Reply with quote

deepag02 wrote:
The problem is 1 month can be 30 days or 31 days or even 28/29 days. Now if my client sets his frequency as monthly and the current date is jan 1st, I need to update the date to feb 1st and then march 1st. If I use INTERGER-OF-DATE and DATE-OF-INTEGER function I would be adding 30 days or so every time. In that case first it will be jan 1st + 30 =


Hello
I don't know if you already have the answer but, you can solve the problem using an internal table where, you have the months numbers and their duration in days. Then, you can access it using the month as an index to obtain the number of days that particular month has and, adding it using INTEGER-OF-DATE and DATE-OF-INTEGER.
I hope this will help.

Regards
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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