SECONDS scalar function¶
Returns an integer representation of the specified TIMESTAMP. The inverse of this function is TIMESTAMP scalar function.
Prototypes¶
SECONDS(ATIMESTAMP TIMESTAMP)
SECONDS(ATIMESTAMP DATE)
SECONDS(ATIMESTAMP VARCHAR(26))
RETURNS BIGINT
Description¶
Returns an integer representation of a TIMESTAMP. This function is a combination of the built-in DAYS and MIDNIGHT_SECONDS functions. The result is a BIGINT (64-bit integer value) representing the number of seconds since one day before 0001-01-01 at 00:00:00. The one day offset is due to the operation of the DAYS function.
Parameters¶
- ATIMESTAMP
- The timestamp to convert to an integer representation. If a DATE is provided, then it will be treated as a TIMESTAMP with the equivalent date portion and a time portion of midnight.
Examples¶
Return an integer representation of the first instant of the year 2010:
VALUES SECONDS(YEARSTART(2010));
1
--------------------
63397987200
Return the number of seconds in the year 2010:
VALUES SECONDS(YEARSTART(2011)) - SECONDS(YEARSTART(2010));
1
--------------------
31536000
See Also¶
- Source code
- TIMESTAMP scalar function
- DAYS (built-in function)
- MIDNIGHT_SECONDS (built-in function)