View previous topic :: View next topic
|
Author |
Message |
deepag02
New User
Joined: 23 Jul 2007 Posts: 20 Location: India
|
|
|
|
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 |
|
|
deepag02
New User
Joined: 23 Jul 2007 Posts: 20 Location: India
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
Back to top |
|
|
deepag02
New User
Joined: 23 Jul 2007 Posts: 20 Location: India
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
Back to top |
|
|
deepag02
New User
Joined: 23 Jul 2007 Posts: 20 Location: India
|
|
|
|
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 |
|
|
deepag02
New User
Joined: 23 Jul 2007 Posts: 20 Location: India
|
|
|
|
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
So was looking for a built in function which can handle all these conditons.. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Antonio Barata Warnings : 1 New User
Joined: 04 Apr 2007 Posts: 37 Location: Lisbon, Portugal
|
|
|
|
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 |
|
|
|