MySQL 8.1
MICROSECOND(time)Parameters
- timeTIME
- Time or datetime
Return value
An integer from 0 to 999999; 0 if there are no fractional seconds; NULL if the value is not recognized
Examples
Microseconds from a time
MySQL 8.1
SELECT MICROSECOND('12:00:00.123456');Half a second
MySQL 8.1
SELECT MICROSECOND('2022-06-16 16:37:03.5');Details
Fractional seconds are stored only if the column has a precision, for example DATETIME(6); for a plain DATETIME the function always returns 0. Likewise, NOW() without an argument gives 0, while NOW(6) gives the microseconds of the current moment.