View previous topic :: View next topic
|
Author |
Message |
a b c d
New User
Joined: 04 Mar 2010 Posts: 13 Location: UK
|
|
|
|
Hi All,
Please let me know how to find the particular day of the week in PL/I.
I have to find the first sunday of the week following the first working day. I able to find the first working day with the help of the existing routines.
For example If we consider July 2010
Then First working day of July 2010 is Thrusday,
and First sunday is 4th July 2010.
In the above example If I am able to find the 1st July 2010 as Thrusday, Then I can add 3 days to get First sunday |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
check the ceedate callable service for the integer_of_date function
which has the chatacteristic that modulo 7 will give the day of the week
integer_of_date(....) // 7
0==> sunday
1
2
3
4
5==> friday
6
up to You to fill the empty slots
but still the issue is not completely defined
standard LE functions will help get the day of week,
they will not help to find out about <working> days
that info requires quite a bit of site specific handling,
fixed holidays ( world, national, local )
variable holidays
... and so on
usually after so many years of data processing every organization ( apart the disorganized ones )
have developed standard functions to take care of the work/holiday issue,
ask Your support !
Quote: |
For example If we consider July 2010
Then First working day of July 2010 is Thrusday,
and First sunday is 4th July 2010. |
but if You consider January 2010
the first working day would be the 4th not the 1st
and the <first> sunday would fall on the 10 |
|
Back to top |
|
|
a b c d
New User
Joined: 04 Mar 2010 Posts: 13 Location: UK
|
|
|
|
Hi enrico,
Integer of date is available in COBOL, here I am looking for PL/I syntax
There are few builtin functions like DAYS and WEEKDAY avaiable on PL/I, but unfortuantly complier is not recognising those... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
a b c d wrote: |
Integer of date is available in COBOL, here I am looking for PL/I syntax
There are few builtin functions like DAYS and WEEKDAY available on PL/I, but unfortunately compiler is not recognising those... |
Then I would suggest that you tell your management that they should seriously start thinking about getting a new release of the PL/I compiler - what stone-age release are you using? |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
how about mayday? |
|
Back to top |
|
|
Sys Edwin
New User
Joined: 18 Oct 2010 Posts: 7 Location: Canada
|
|
|
|
a b c d wrote: |
Hi All,
Please let me know how to find the particular day of the week in PL/I.
I have to find the first sunday of the week following the first working day. I able to find the first working day with the help of the existing routines.
For example If we consider July 2010
Then First working day of July 2010 is Thrusday,
and First sunday is 4th July 2010.
In the above example If I am able to find the 1st July 2010 as Thrusday, Then I can add 3 days to get First sunday |
Funny I should come across this question today, because I have just been writing some GAL code to do exactly this and to submit a job. I know this reply is off topic, but the congruence with what I was doing is amusing. I took some examples from the manual and coded this to submit a job every Sunday that followed a working day to run a weekly backup. This code is much more rigorous than what you are looking for because it defines working days in relation to holidays and non-working days, not just weekends, but I thought it might amuse you.
DEFINE CATEGORY ( NONWORK )
CONTAINS DAY( WEEKEND )
CONTAINS CATEGORY( HOLIDAY BANK_HOLIDAY )
DESCRIPTION ( 'DAYS WE DONT WORK' )
*
DEFINE CATEGORY ( WORKDAY )
CONTAINS DAY( WEEKDAY )
EXCEPT CATEGORY( NONWORK )
DESCRIPTION ( 'DAYS WE DO WORK' )
*
DEFINE DAY ( NEWYEARS )
AS ( 1ST DAY OF YEAR)
ADD CATEGORY ( HOLIDAY)
DESCRIPTION ( 'US FEDERAL HOLIDAY' )
*
DEFINE DAY ( NEWYEARS_DAY )
AS ( NEWYEARS WHERE ( DOW IS NOT (SAT SUN))
OR FIRST MONDAY OF YEAR )
ADD CATEGORY ( BANK_HOLIDAY )
DESCRIPTION ( 'UK BANK HOLIDAY' )
*
DEFINE DAY (WEEKLY_BACKUP)
AS (FIRST SUN AFTER WORKDAY)
*
* Submit the weekly backup every Sunday that follows a working day
*
AT 04:40 EVERY WEEKLY_BACKUP
SUB(SYSA.SYS.CNTL(SYSAWKBK)) |
|
Back to top |
|
|
|