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
 

 

Find out the last day and next day of a month

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Find out the last day and next day of a month
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    Post subject:
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

Senior Member


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

PostPosted: Tue Aug 05, 2008 5:20 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Tue Aug 05, 2008 5:27 pm    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Tue Aug 05, 2008 5:39 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

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

Senior Member


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

PostPosted: Wed Aug 06, 2008 2:25 pm    Post subject:
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    Post subject:
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    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
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
No new posts Find out a active PGM jpsager JCL & VSAM 10 Fri Oct 07, 2016 4:32 pm


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