I'm trying add time in mysql which is having format (hh:mm:ss.ms) but after addition millisecond value is getting 00
what i tried is
SEC_TO_TIME(sum(time_to_sec(TIMEDURATION)))
as i got to know it is converting time into seconds not getting anything for milisecond. my time format is something like this 19:30:10.903
By design, time_to_sec()
loses the fractional seconds. On the other hand, sec_to_time()
is capable of properly handling fractional seconds.
One solution is to sum the fractional seconds separately, like, then add them back before converting back to a time:
sec_to_time(sum(time_to_sec(timeduration)) + sum(microseconds(timeduration)) / 1000000)