Format decimal day as 24-hour HH:MM:SS How, w/o rounding up, do I get 'Decimal Day' into HH:MM:SS format using SQL?
Using MariaDB 5.x, one of the DB fields contains a pseudo date-time, as day.time.




DB 'Time' col
Day
Decimal 24-hour time
HH:MM:SS Time




0.1234567890
0
.1234567890
02:57:46


1.4567890123
1
.4567890123
10:57:46


2.8901234567
2
.8901234567
21:21:46




I'm able to pull the day out from the TIME column using:  SELECT dbTime - MOD(dbTime, 1) AS 'Day'
And I can separate the decimal time using:  MOD(dbTime, 1) AS 'Decimal Day'
I can't figure out how to get 'Decimal Day' into HH:MM:SS format? I have played around with two different numbers using the following SQL, which gives me the individual HH:MM:SS numbers, but the numbers always round up whenever I try using format, cast, or convert.




Decimal Day
HH:MM:SS Time




.51923075705577
12:27:41


.52923075705577
12:42:05




SELECT .51923075705577 * 24 AS 'hour', 
       mod((.51923075705577 * 24), 1) * 60 AS 'minute', 
       mod((mod((.51923075705577 * 24), 1) * 60), 1) * 60 AS 'seconds';

The times shown above are the desired result.
Thanks for any assistance on this one.
mysql&gt; SELECT SEC_TO_TIME(86400 * .51923075705577);
+--------------------------------------+
| SEC_TO_TIME(86400 * .51923075705577) |
+--------------------------------------+
| 12:27:41.537410                      |
+--------------------------------------+

(There are 86400 seconds in a day.)
mysql&gt; SELECT SEC_TO_TIME(86400 * 0.999999);
+-------------------------------+
| SEC_TO_TIME(86400 * 0.999999) |
+-------------------------------+
| 23:59:59.913600               |
+-------------------------------+

mysql&gt; SELECT SEC_TO_TIME(86400 * 0.001);
+----------------------------+
| SEC_TO_TIME(86400 * 0.001) |
+----------------------------+
| 00:01:26.400               |
+----------------------------+

To avoid fractional seconds:
+---------------------------------------------+
| SEC_TO_TIME(ROUND(86400 * .51923075705577)) |
+---------------------------------------------+
| 12:27:42                                    |
+---------------------------------------------+
+---------------------------------------------+
| SEC_TO_TIME(FLOOR(86400 * .51923075705577)) |
+---------------------------------------------+
| 12:27:41                                    |
+---------------------------------------------+