MySQL MICROSECOND Function

MySQL Microsecond Date Function will returns the microseconds from the given time or DateTime expression. The syntax of the Microsecond Function in MySQL is as shown below:

MICROSECOND(DateTime or time expression);

MySQL Microsecond function Example

These examples help you understand the use of this Microsecond function. Here, we are returning the Microseconds from the time expression, and the Date & time expression.

SELECT MICROSECOND('10:12:22.223156');

SELECT MICROSECOND('12:12:44.123160');

SELECT MICROSECOND('2019-02-14 10:12:22.223156');
MySQL MICROSECOND Function 1

Let us see another example of Microsecond Date Function. Here, we are trying to return the Microseconds from the date and time returned by the Now(), and UTC_TIMESTAMP function.

SELECT MICROSECOND(NOW());

SELECT MICROSECOND(UTC_TIMESTAMP());

SELECT MICROSECOND('12:12:62.123160');

From the below screenshot, MICROSECOND(’12:12:62.123160′); means we are trying to get a microsecond from an invalid date. That’s why MySQL returns NULL.

MySQL MICROSECOND Function 2