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

Get the last working day of the month


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
santohsks1987
Warnings : 1

New User


Joined: 29 Dec 2010
Posts: 31
Location: Mumbai

PostPosted: Tue Apr 26, 2011 4:51 pm
Reply with quote

Hi everyone,

I want to get the last working day of the month. However holidays need not be taken into consideration. It should be a weekday.

I need the day i.e., Monday or Tuesday or........

Can anyone help me to get it? icon_question.gif

Warning: Title Edited
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Apr 26, 2011 4:54 pm
Reply with quote

Does your version/release of COBOL support Intrinsic Functions?

Bill
Back to top
View user's profile Send private message
santohsks1987
Warnings : 1

New User


Joined: 29 Dec 2010
Posts: 31
Location: Mumbai

PostPosted: Tue Apr 26, 2011 4:56 pm
Reply with quote

Yes, it supports.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Apr 26, 2011 4:57 pm
Reply with quote

Could you have come up with a less meaningless subject line?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Apr 26, 2011 4:58 pm
Reply with quote

Your first place to look should be your site. Most sites have some sort of common date processing routine available; it may be that this routine can provide you what you need. If not, Google is your friend. Googling zeller's congruence returns 2,750 hits and should solve your problem for you -- with a little thought on your part.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Tue Apr 26, 2011 5:06 pm
Reply with quote

After setting DD to 1 and adding 1 to MM (checking for 13), INTEGER-OF-DATE and subtract 1 day and then DATE-OF-INTEGER for the last day of the month. It will give you date, though.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 28, 2011 4:44 am
Reply with quote

I used to use a table with the names for the first week of January 1980. For each year greater, shuffle the table around once. For the year after a leap-year do it twice. Then you have the days for the first week of the year you are interested in. Mod 7 of your DDD, subscript/index to day name.

To find what is a leap year, these days, easy - convert 31 December of the year you are interested in. If 366, a leap year. You could calculate, from the first leap year you find, and subtracting the years, then do one shuffle (or just a starting point to apply the mod 7 to), but you have to watch for 2000.

Zeller looks wonderful, but I'd kind of stick to something along the above lines. Of course, either way, it has to work is the important bit.
Back to top
View user's profile Send private message
santohsks1987
Warnings : 1

New User


Joined: 29 Dec 2010
Posts: 31
Location: Mumbai

PostPosted: Thu Apr 28, 2011 9:41 am
Reply with quote

Thank you guyz for the replies..... i am working on the logic......
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Apr 28, 2011 10:35 am
Reply with quote

Quote:
last working day of the month. However holidays need not be taken into consideration


so it is not the last working-day,

you want the last
monday,tuesday,wednesday,thursday or friday - whichever it is, holiday or not
of the month.

a working-day can not be a holiday.....
Back to top
View user's profile Send private message
santohsks1987
Warnings : 1

New User


Joined: 29 Dec 2010
Posts: 31
Location: Mumbai

PostPosted: Thu Apr 28, 2011 10:38 am
Reply with quote

Hi,

Yes, i need the last weekday of the month. i.e., it should not be saturday or sunday, it should be last Monday, Tuesday, Wednesday, Thursday, Friday.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Apr 28, 2011 12:08 pm
Reply with quote

Determine the weekday of the last calendar day in the month. If it is a Sunday or a Saturday, you then now that the last working day is a Friday.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 28, 2011 12:51 pm
Reply with quote

Bill Woodger wrote:
I used to use a table with the names for the first week of January 1980. For each year greater, shuffle the table around once. For the year after a leap-year do it twice. [...]


There is nothing "magical" about 1980, just the year I wrote the program, so more of the dates going in were from that year. It could also go "backwards", just shuffle in the other direction.

Implemented as a called program, and we ended up using it quite a lot. Needs two tables, one to stay in place for the original year (so, 2011), one to be shuffled. If called with the same year as last call, obviously do nothing but return the already correct table.

However, once we had a Scheduling Package, a couple of the requirements dropped out, because it was more sensible to do it from the Scheduler. Depends on your task and available software.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Apr 28, 2011 12:55 pm
Reply with quote

santohsks1987 wrote:
I want to get the last working day of the month. However holidays need not be taken into consideration. It should be a weekday.

Define holiday!

Just Sat/Sun, or Easter (possible to calculate, but pretty hard), Christmas, bank holidays, Thanksgiving, independence day?
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Thu Apr 28, 2011 5:36 pm
Reply with quote

prino wrote:
santohsks1987 wrote:
I want to get the last working day of the month. However holidays need not be taken into consideration. It should be a weekday.

Define holiday!

Just Sat/Sun, or Easter (possible to calculate, but pretty hard), Christmas, bank holidays, Thanksgiving, independence day?
And don't forget that new holidays can be added at any time. Here in Ontario (Canada) a new one was recently added in February. But only in Ontario.... other regions of the country have different holiday calendars.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 29, 2011 11:27 pm
Reply with quote

Quote:
Define holiday!


Any day when management thinks IT staff are "essential services", so should be working anyway.
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 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 PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
Search our Forums:

Back to Top