View previous topic :: View next topic
|
Author |
Message |
Vidhya Karthi
New User
Joined: 28 Aug 2007 Posts: 18 Location: Chennai
|
|
|
|
Hi All,
I want to find out the last day and next day of a month. Input will be a date field in the format (YYYY-MM-DD).
Due to performance issues, we have been asked not to use DB2 functions in our programs. I need the date calculation to be done in Cobol. Can anyone help me out on this?
Thanks in advance |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
What you mean by last day and next day of a month ?
if date is 2008-08-05 what is the o/p required ?
try using functions INTEGER-OF-DATE and DAY-OF-INTEGER .. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Perhaps I can get the meaning of "Last day of month" but what is "next day of a month "..curious to know.. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
That only happens in leap years, the 28th is the last day of February, and the 29th is the next day of that month |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
this is an interview or school task. I don't see much business use for this unless it is tied to working days, in which case there needs to be some kind of holiday consideration.
'sides, whoever dictated 'no db2, due to performance considerations', is just one of the many computer iliterates who have beaten the phrase 'due to performance considerations' into the ground. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
expat wrote: |
That only happens in leap years, the 28th is the last day of February, and the 29th is the next day of that month |
Oh..this was not known to me... |
|
Back to top |
|
|
kumara.kranthi
New User
Joined: 03 Nov 2006 Posts: 21
|
|
|
|
Hey,
Try like this
COMPUTE DIFF = FUNCTION INTEGER-OF-DATE(DATE1).
ADD 1 TO DIFF.
COMPUTE DATE2 = FUNCTION DATE-OF-INTEGER(DIFF) |
|
Back to top |
|
|
Vidhya Karthi
New User
Joined: 28 Aug 2007 Posts: 18 Location: Chennai
|
|
|
|
Hi Kumara,
Thanks for the reply. It works for next day.
Anuj,
Next day example:
ex: 2008/01/31
next day: 2008/02/01 |
|
Back to top |
|
|
kumara.kranthi
New User
Joined: 03 Nov 2006 Posts: 21
|
|
|
|
How u r passing the date, u r using thru file. |
|
Back to top |
|
|
Vidhya Karthi
New User
Joined: 28 Aug 2007 Posts: 18 Location: Chennai
|
|
|
|
yes, i'm done with that.. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Thanks.
Quote: |
yes, i'm done with that.. |
Did you get the expected output ? |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Vidhya,
Move your date to a wrk fld. Add 1 to the mm. If it's 13 move 1 to mm add 1 to yyyy.
In either case move 1 to dd. That gives you the "next day".
Now use Iteger-of-date function, then subtract 1 from the integer, then use Date-of-integer. That gives you the last DOM. |
|
Back to top |
|
|
|