i want to get the total number of ot hours in given month it may be more 1000 hours .i already have time sum query but it limited 839:59:59 .how do ignore or anther way to do this task.(ot_hours store in VARCHAR
data type)
try query
SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( `ot_hour` ) ) ) AS timeSum
FROM groupotrequest
INNER JOIN department
ON department.dept_Id = groupotrequest.dept_Id
WHERE groupotrequest.dept_Id = $dept_Id AND month LIKE '$passmonth%' AND overtime_status=6
sample data
id month ot_hour dept_Id overtime_status overtime_type date
1 2019-10 2535:00:00 28 6 main_ot 2019-11-21 07:26:00
2 2019-11 2535:00:00 28 6 main_ot 2019-11-21 07:27:00
3 2019-10 20:00 28 6 sub_ot 2019-11-21 07:28:00
4 2019-11 20:00 28 6 sub_ot 2019-11-21 07:30:00
i want to get 2019-11 total ot hours as 2555:00:00
function GetApprovedOt($connect,$dept_Id,$passmonth)
{
$query01 =$connect->prepare('SELECT SUM( TIME_TO_SEC( `ot_hour` ))
FROM groupotrequest
INNER JOIN department
ON department.dept_Id = groupotrequest.dept_Id
WHERE groupotrequest.dept_Id = :dept_Id AND month LIKE :passmonth% AND overtime_status=6');
$query01->execute([
':passmonth' => $passmonth,
':dept_Id' => $dept_Id
]);
list ($totalMins, $remngSecs) = gmp_div_qr($query01->fetchColumn(), 60);
list ($totalHour, $remngMins) = gmp_div_qr($totalMins, 60);
echo "Worked a total of $totalHour:$remngMins:$remngSecs.";
}
i try this also .it also does not working