TIMESTAMP_SECONDS
Description
The TIMESTAMP_SECONDS
function is used to convert a number of seconds (bigint
type) representing time into a timestamp (timestamp
type). This function conveniently converts the number of seconds since the Unix epoch (00:00:00 UTC on January 1, 1970) into date and time format.
Syntax
Parameters
seconds
: A parameter of typebigint
, representing the number of seconds since the Unix epoch.
Return Result
- Returns a result of type
timestamp
, representing the date and time corresponding to the input seconds.
Usage Example
- Calculate the current Unix timestamp and convert it to timestamp format:
This will return the current date and time when the query is executed.
- Convert a specific number of seconds to a timestamp:
This will return 2023-09-22 14:27:45
, indicating the date and time corresponding to the input seconds.
- Calculate the Unix timestamp for a specific date and time and convert it to timestamp format:
This will return 2023-09-22 14:27:45
, which is the same as the input date and time.
By using the TIMESTAMP_SECONDS
function, you can easily convert between different time formats and representations to better handle and analyze data.