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

Find out the last day and next day of a month


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vidhya Karthi

New User


Joined: 28 Aug 2007
Posts: 18
Location: Chennai

PostPosted: Tue Aug 05, 2008 11:53 am
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Aug 05, 2008 3:58 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Aug 05, 2008 5:20 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Tue Aug 05, 2008 5:27 pm
Reply with quote

That only happens in leap years, the 28th is the last day of February, and the 29th is the next day of that month icon_eek.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 05, 2008 5:35 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Aug 05, 2008 5:39 pm
Reply with quote

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 icon_eek.gif
Oh..this was not known to me... icon_neutral.gif
Back to top
View user's profile Send private message
kumara.kranthi

New User


Joined: 03 Nov 2006
Posts: 21

PostPosted: Wed Aug 06, 2008 12:14 pm
Reply with quote

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
View user's profile Send private message
Vidhya Karthi

New User


Joined: 28 Aug 2007
Posts: 18
Location: Chennai

PostPosted: Wed Aug 06, 2008 12:43 pm
Reply with quote

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
View user's profile Send private message
kumara.kranthi

New User


Joined: 03 Nov 2006
Posts: 21

PostPosted: Wed Aug 06, 2008 1:02 pm
Reply with quote

How u r passing the date, u r using thru file.
Back to top
View user's profile Send private message
Vidhya Karthi

New User


Joined: 28 Aug 2007
Posts: 18
Location: Chennai

PostPosted: Wed Aug 06, 2008 2:05 pm
Reply with quote

yes, i'm done with that..
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Wed Aug 06, 2008 2:25 pm
Reply with quote

Hi,

Quote:
Next day example:
Thanks.
Quote:
yes, i'm done with that..
Did you get the expected output ?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Aug 06, 2008 7:02 pm
Reply with quote

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
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 sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Compare 2 alphabets in a REXX and fin... CLIST & REXX 2
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top