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

Equivalent for FUNCTION ADD-DURATION in COBOL 370


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
www.ibmmainframes.com/viewtopic.php?t=30525&highlight=integerofdate
www.ibmmainframes.com/viewtopic.php?t=33741&highlight=integerofdate
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
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
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
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

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
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
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: 691
Location: Earth

PostPosted: Fri Nov 21, 2008 3:41 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Nov 21, 2008 4:56 pm
Reply with quote

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

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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top