The function converts a DATETIME value into a Unix timestamp (in seconds) starting from 1970-01-01 00:00:00 UTC.
SECOND_TIMESTAMP(<datetime>)
| Parameter | Description |
|---|---|
<datetime> | Required. The DATETIME value to be converted into a Unix timestamp. |
<datetime> is NULL, the function returns NULL.<datetime> is out of valid range, the function may return an error or unexpected value.SELECT SECOND_TIMESTAMP('2025-01-23 12:34:56');
+----------------------------------------------------------------+ | second_timestamp(cast('2025-01-23 12:34:56' as DATETIMEV2(0))) | +----------------------------------------------------------------+ | 1737606896 | +----------------------------------------------------------------+