Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 6968
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 Command to find TMEMBER name for a TPIPE Siva NKK Kothamasu IMS DB/DC 0 Wed Aug 16, 2017 6:08 pm
No new posts Reg:Displaying the particular month o... bhavana yalavarthi All Other Mainframe Topics 4 Sat Jul 08, 2017 8:13 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us