I need to get the number of working days for each month to date. For example, if today is the 25th of August, I have to calculate (25-(sum of holidays)).
However, for some archaic reason the table only saves Sundays and national holidays, despite that Saturdays are also off days. The table cannot be edited.
So I need to find a way to also count the Saturdays. Since Saturdays and Sundays always come in pair and Saturdays come before Sundays, I can just double the number of Sundays for each month.
The table of holidays (t_holiday) is saved as such:
| date | desc |
|2016-01-01 |New Year's|
|2016-01-03 | Sunday |
|2016-01-10 | Sunday |
|2016-01-17 | Sunday |
|2016-01-24 | Sunday |
|2016-01-31 | Sunday |
I could come up with the the queries for just counting the non-weekend holidays and the weekends separately, but I have no idea on how to combine them in one query.
Holidays (non-weekend)
SELECT ((25) -COUNT(date))
FROM t_holiday
WHERE date between '2016-01-01' and '2016-01-31'
AND desc != 'Sunday'
Weekends (Saturdays and Sundays)
SELECT ((25) - (2*COUNT(holiday_date)))
FROM t_holiday
WHERE date between '2016-01-01' and '2016-01-31'
AND desc = 'Sunday Off'