I need to calculate what percentage of the business day certain period of time is.
To get business day duration I use a query like this:
SELECT
timeOpen,
timeClose,
TIMEDIFF(timeClose, timeOpen) AS hours
FROM businessHours
The results I get are in the following format: HH:MM, like 11:00 or 10:30.
I'm a bit confused how to calculate what percentage another time period, like 4 hrs is of the business day hours is when I have half-hour values, like 10:30. I do not have other minutes, i.e. either even or half-hour.
Other than that I think my math will be something like this:
(4 x 100) / 10.5
Do I need to use some sort of str_replace
to convert time to integer?