PHP kôd:
SELECT id, start, end,
CASE WHEN start > end AND end > 0 AND CAST('01:38:14' AS time) < end THEN 1 ELSE 0 END AS yesterday,
CASE WHEN CAST('01:38:14' AS time) BETWEEN start AND end THEN 1 ELSE 0 END AS today
FROM schedules
WHERE
(
/* this will handle eg 09-17 situations or one day shifts */
CAST('01:38:14' AS time) BETWEEN start AND end
OR
/* this will handle eg 18-03 situations or two day shifts */
NOT (CAST('01:38:14' AS time) BETWEEN end AND start) AND start > end
)
AND staff_id = 93
HAVING today = 1 OR yesterday = 1
LIMIT 1