Tuesday, 10 September 2013

How do I convert negative time value into 24 hour time in MYSQL?

How do I convert negative time value into 24 hour time in MYSQL?

I have a column in a table of type TIME. I want to get a result that
applies a time shift that results in a 24 hour clock representation of
that shift. To add the shift, my query contains...
select addtime(boo,'01:00:00') as yada
But any value that gets taken out of the 24 hour range ends up outside the
24 hour range, such as...
23:45 ends up as 24:45 (when I want 00:45:00)
If I go the other way and subtract the hour from a value less than 1am, I
get...
00:15 ends up as -00:45:00 when I want (23:15:00)
Now, I understand that the TIME format in MYSQL is "duration" and not the
actual "time", but for the life of me I can't figure out how to convert to
an actual clock time as outlined above. Please help me or kill me. Either
will end my suffering.

No comments:

Post a Comment