TIMESTAMP_MICROS
The TIMESTAMP_MICROS() function converts a given UNIX timestamp value in microseconds since 1970-01-01 00:00:00 UTC into a timestamp. Its syntax can be seen below:
Its input type is an int64 expression representing a UNIX timestamp in microseconds, and the return data type is a timestamp.
The below example uses the TIMESTAMP_MICROS() function to convert a given UNIX timestamp in microseconds into a timestamp without a timezone:
The final output will be as follows:
Let’s suppose we have a table named timemirco_example with the following UNIX time values in microseconds in the unix_timestamp column:
The above query will show the following table:
We want to convert all UNIX timestamp values in microseconds to timestamp values. To do that, we have to run the following query:
The output displays all the entries in the table in UNIX timestamp format (in microseconds) in the unix_timestamp column and in the timestamp format in the column timestamp_value without timezone:
