MICROSECOND
MICROSECOND(expression)
Section titled “MICROSECOND(expression)”- expression: This parameter is required and specifies the time value for which to return the microsecond part. For example, if the provided time value is ‘2009-05-18 15
Example
Section titled “Example”SELECT MICROSECOND('2022-03-15 12:35:49.123456');Output
Section titled “Output”123456Explanation
Section titled “Explanation”In MySQL, the MICROSECOND() function extracts the microsecond part from a time or datetime value. In the provided example, MICROSECOND('2022-03-15 12:35:49.123456') is used to extract microseconds from the provided datetime value, resulting in the output 123456.
MICROSECOND(timestamp)
Section titled “MICROSECOND(timestamp)”- timestamp: The input parameter representing the date and time value from which the microsecond part is to be extracted. It must be of a timestamp data type, string, or an expression that evaluates to a date and time value.
Example
Section titled “Example”SELECT EXTRACT(MICROSECOND FROM TIMESTAMP '2000-12-16 12:21:13.456789');Output
Section titled “Output”456789Explanation
Section titled “Explanation”The EXTRACT() function retrieves a field, such as MICROSECOND, from a timestamp value. In the given example, it extracts the microsecond portion from the specified timestamp, resulting in 456789.
MICROSECOND( date_value )
Section titled “MICROSECOND( date_value )”- date_value: The exact point in time from which the microseconds are to be extracted, expressed in a valid date format.
Example
Section titled “Example”SELECT DATEPART(MICROSECOND, '00:00:01.1234567') AS Microseconds;Output
Section titled “Output”Microseconds------------456700Explanation
Section titled “Explanation”The DATEPART function in SQL Server is used to return a part of a date such as year, month, day, hour, minute, second, or microsecond. In the example above, the DATEPART function is used to extract the microsecond portion of the time ‘00:00:01.1234567’. The output shows the microsecond as ‘456700’.
MICROSECOND(EXPRESSION)
Section titled “MICROSECOND(EXPRESSION)”- expression: Represents the input timestamp or interval value from which the microsecond part is to be extracted. If a date value is used as the expression, the microsecond part is always 0 because Oracle Database doesn’t store fractional seconds in a DATE value. If it’s a timestamp or interval value, the microsecond part is extracted.
Example
Section titled “Example”SELECT EXTRACT(MICROSECOND FROM SYSTIMESTAMP) AS MicrosecondsFROM dual;Output
Section titled “Output”MICROSECONDS------------582000Explanation
Section titled “Explanation”In this example, the EXTRACT function is used in conjunction with the SYSTIMESTAMP function to obtain the current microsecond value from the system timestamp. This value is then given an alias Microseconds for the sake of clarity. The FROM dual clause is a standard feature in Oracle SQL for performing calculations, system calls, and other non-table operations.