View previous topic :: View next topic
|
Author |
Message |
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
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?
Warning: Title Edited |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Does your version/release of COBOL support Intrinsic Functions?
Bill |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
Yes, it supports. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
Could you have come up with a less meaningless subject line? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
Thank you guyz for the replies..... i am working on the logic...... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1316 Location: Vilnius, Lithuania
|
|
|
|
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 |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 767 Location: Whitby, ON, Canada
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Any day when management thinks IT staff are "essential services", so should be working anyway. |
|
Back to top |
|
|
|