I have table of vacation:
`holiday` (`ID_holiday`, `holiday_start`, `holiday_end`, `holiday_typ`, `ID_empl`)
(18, '2019-07-07', '2019-07-18', 1, 6),
(19, '2019-06-25', '2019-06-25', 3, 5),
(20, '2019-05-30', '2019-06-05', 1, 6),
(21, '2019-05-30', '2019-05-30', 1, 5),
(22, '2019-06-30', '2019-06-30', 1, 5),
(23, '2019-06-30', '2019-06-30', 1, 6),
I need the number of days of vacation per month and year (sum).
Vacation is entered during weekends and public holidays - I only need the sum of working days.
holiday_typ 1 .. 1 day
holiday_typ 3 .. 0.5 day
Is it possible to solve it by mysql query or mysql+php? Thanks
I try .. for one employer:
for ($Day = 1; $Day <= $last_day_month; $Day++) {
$date = $YYYY.'-'.$Month.'-'.$Day;
$cz_svatek = cz_svatek ($Month, $Day, $YYYY); // return name of public holiday or ''
$sql = "SELECT *
FROM holiday
JOIN holiday_typ USING (ID_holiday_typ)
WHERE ID = ".$ID."
AND holiday_start <= '".$date."'
AND holiday_end >= '".$date."'";
$result = MySQL_Query($sql);
while ($dbMuf = MySQL_Fetch_Array($result)){
if( date("N", mktime(12, 0, 0, $Month, $Day, $YYYY)) < 6 && $cz_svatek == '') $holiday[$dbMuf["ID_dov_typ"]]++;
}
$sum_holiday = $holiday[1]+0.5*$holiday[3];