Skip to content
Advertisement

MySQL how get middle point between two given times

I have 2 times value

06:00:00 and 14:00:00

expected result is

10:00:00

FYI. I want to write this into my trigger

Advertisement

Answer

You can convert your times to seconds, then find the middle value, and convert back to time

The middle value of two numeric values is simply (a + b) / 2

SEC_TO_TIME((TIME_TO_SEC(time1) + TIME_TO_SEC(time2)) / 2)
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement