Quote:
|
Originally Posted by annamaria
Is there a way in SQL for IBM z/OS to count days between two dates according to a specific calendar (for example, Italian banking holidays calendar)?
|
You'll indeed have to implement that function (UDF) yourself: there's no standard "NoOfWeekDays" function or so. Let alone one that knows about Italian banking holidays.
Ingredients which will have to be used are:
- the DAYS function. argument: an expression of datatype DATE; returns: an integer
The difference between two DAYS return values is the nr. of days "between" the two, i.e., it will be 0 for equal dates, 1 or -1 for two consecutive days, etc.
- the DAYOFWEEK function: argument: a DATE; returns: 1 for Sunday, 2 for Monday, ... 7 for Saturday.
- a (small) table summing up the Italian banking holidays. Single column, datatype DATE.
Around this, you may write a relatively simple UDF which returns the number of working days between two given dates.
Alternatively, also a single SELECT statement could do this; in that case it will need to be a recursive one, still using the three mentioned ingredients.
(Its implementation is left as an exercise... ;-)