How can I round times in MySQL to the nearest 15 minutes (e.g. 0,15,30,45)?
Here is some rough code that I used that got the results really close to what I wanted. Because I didn't use seconds I just chose minutes near the half way point.
SELECT
CASE
WHEN minute(timeIn) BETWEEN 0 and 7 THEN SEC_TO_TIME((TIME_TO_SEC(timeIn) DIV 3600) * 3600)
WHEN minute(timeIn) BETWEEN 8 and 22 THEN ADDTIME(SEC_TO_TIME((TIME_TO_SEC(timeIn) DIV 3600) * 3600), '00:15:00')
WHEN minute(timeIn) BETWEEN 23 and 37 THEN ADDTIME(SEC_TO_TIME((TIME_TO_SEC(timeIn) DIV 3600) * 3600), '00:30:00')
WHEN minute(timeIn) BETWEEN 38 and 52 THEN ADDTIME(SEC_TO_TIME((TIME_TO_SEC(timeIn) DIV 3600) * 3600), '00:45:00')
WHEN minute(timeIn) BETWEEN 53 and 59 THEN ADDTIME(SEC_TO_TIME((TIME_TO_SEC(timeIn) DIV 3600) * 3600), '01:00:00')
END as 15_min
FROM
clock.punches;