MySQL Microseconds in Timestamp Value Conversion to Integer



As we know that the value of timestamp can be converted to a number of seconds with the help of UNIX_TIMESTAMP() function. MySQL would ignore the microseconds added to the value of timestamp because the value of UNIX_TIMESTAMP is only 10digits long.

Example

mysql> SELECT UNIX_TIMESTAMP('2017-10-22 04:05:36')AS 'Total Number of Seconds';
+-------------------------+
| Total Number of Seconds |
+-------------------------+
| 1508625336              |
+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT UNIX_TIMESTAMP('2017-10-22 04:05:36.200000')AS 'Total Number of Seconds';
+-------------------------+
| Total Number of Seconds |
+-------------------------+
| 1508625336              |
+-------------------------+
1 row in set (0.00 sec)

The queries above shows that the output remains same even after adding the 6 digits value of microseconds.

Updated on: 2020-06-20T06:34:20+05:30

104 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements