MySQL Date/Time microsecond() Function

Last Updated : 13 Feb 2026

The microsecond() is a MySQL date/time function . It is used to get the value of microsecond from given datetime or time. It takes the date-time value as the input parameter and returns a integer value between 0 to 999999.

Some of the functions of the microsecond function are given below:

  • This function is useful in calculating high-precision time calculation values.
  • It enables you to perform various types of precise measurements, comparisons, and calculations.
  • It is used to measure the execution time of queries and measure time intervals.

In this article, we will understand the concept of MySQL Date/Time microsecond function in detail with its various working examples.

Syntax

Parameter:

Date_value: datetime or time value for getting microsecond.

Returns:

This function returns the microsecond portion of a date value.

Example 1

Explanation: While executing the above query, the microsecond() function returns the microsecond value from the given date and time.

Output: The output of this example is given below.

MySQL Datetime microsecond() Function

Example 2

Explanation: While executing the above query, the microsecond() function returns the microsecond from the given date and time.

Output: The output of this example is given below.

MySQL Datetime microsecond() Function

Using MySQL Date/Time microsecond function in a Table column

We can use the MySQL DateTime microsecond() function in a table to return the microsecond from the table column.

Following the steps below to perform the functionality of MySQL microsecond() function in a column of the table.

Step 1: Create a table named Order_Details using the CREATE TABLE statement.

Step 2: After that INSERT data into a table using the INSERT TABLE statement.

Step 3: To check the information with the use of SELECT statement, whether the data is inserted or not.

OIDNameDepartmentOrder_DateAmountOrder_Time
101Anjana GuptaClothes2025-10-15150010:20:20.123456
102Priyanka SharmaAccessories2025-11-0550015:10:10.999999
103Bobby KapoorFood2025-10-0880010:30:40.999999
104Alisha SharmaFinance2025-11-0760005:40:25.000023
105Eshant SharmaClothes2025-10-05100008:30:50.900000
106Ravi DubeyClothes2025-10-15150010:20:25.000222

Example:

Explanation: On execution of the above statement, the microsecond function is used to retrieve the microseconds from the Order_Time column in the Order_Details table.

OIDNameDepartmentOrder_DateAmountResult
101Anjana GuptaClothes2025-10-151500123456
102Priyanka SharmaAccessories2025-11-05500999999
103Bobby KapoorFood2025-10-08800999999
104Alisha SharmaFinance2025-11-0760023
105Eshant SharmaClothes2025-10-051000900000
106Ravi DubeyClothes2025-10-151500222

Using MySQL DateTime microsecond function in a Table with a WHERE Clause

We can use the MySQL DateTime microsecond() function in a table to return the microsecond from the table column. By using the WHERE clause we can restrict the data.

Sample Table: Order_Details

OIDNameDepartmentOrder_DateAmountOrder_Time
101Anjana GuptaClothes2025-10-15150010:20:20.123456
102Priyanka SharmaAccessories2025-11-0550015:10:10.999999
103Bobby KapoorFood2025-10-0880010:30:40.999999
104Alisha SharmaFinance2025-11-0760005:40:25.000023
105Eshant SharmaClothes2025-10-05100008:30:50.9
106Ravi DubeyClothes2025-10-15150010:20:25.000222

Example:

Explanation: On execution of the above statement, the microsecond function is used to retrieve the microseconds from the Order_Time column in the Order_Details table WHERE the value of Amount column is greater than 500.

OIDNameDepartmentOrder_DateAmountResult
101Anjana GuptaClothes2025-10-151500123456
103Bobby KapoorFood2025-10-08800999999
104Alisha SharmaFinance2025-11-0760023
105Eshant SharmaClothes2025-10-051000900000
106Ravi DubeyClothes2025-10-151500222

Next TopicMySQL datetime