I have a decimal value say 123.77
Now i want to convert it into corresponding degree
, minute
, second
value using MySQ
Thinking out of the box, by borrowing a different Babylonian-based metric:
mysql> SELECT TIME_FORMAT("%H°%i'%s", SEC_TO_TIME(ROUND(3600 * -1.234)));
+-------------------------------------------------------------+
| TIME_FORMAT("%H°%i'%s", SEC_TO_TIME(ROUND(3600 * -1.234))) |
+-------------------------------------------------------------+
| -01:14:02 |
+-------------------------------------------------------------+
mysql> SELECT TIME_FORMAT("%H°%i'%s", SEC_TO_TIME(ROUND(3600 * -123.77)));
+--------------------------------------------------------------+
| TIME_FORMAT("%H°%i'%s", SEC_TO_TIME(ROUND(3600 * -123.77))) |
+--------------------------------------------------------------+
| -123:46:12 |
+--------------------------------------------------------------+
(The ROUND
is to avoid getting 3 decimal places in the answer.)