In BigQuery Legacy Sql, we use timestamp_to_sec() function to convert timestamp to seconds. What is its equivalent in BigQuery Standard SQL?
DATETIME. TIMESTAMP. The date in the format %Y-%m-%d. 2021-01-20.
Datetime type: comprises both calendar date and time. It does not store time zone information: YYYY-MM-DD HH:MM:SS (e.g. ). Timestamp type: comprises date, time, and time zone information.
To record a date or time, use a datetime2 data type. So you cannot convert a SQL Server TIMESTAMP to a date/time - it's just not a date/time. But if you're saying timestamp but really you mean a DATETIME column - then you can use any of those valid date formats described in the CAST and CONVERT topic in the MSDN help.
BigQuery Legacy SQL
SELECT TIMESTAMP_TO_SEC(CURRENT_TIMESTAMP())
BigQuery Standard SQL
SELECT UNIX_SECONDS(CURRENT_TIMESTAMP())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With