How to select timestamp(stored as seconds) as human readable datetime in Google Bigquery?
schema
id(STRING) | signup_date(TIMESTAMP)
I wrote a query using DATE
function, but getting error
SELECT DATE(create_date) FROM [accounts]
Error: Invalid function name: DATE; did you mean CASE?
Thanks!
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.
You can simply use the fromtimestamp function from the DateTime module to get a date from a UNIX timestamp. This function takes the timestamp as input and returns the corresponding DateTime object to timestamp.
I think I found a working solution from Bigquery reference page. Basically BigQuery stores TIMESTAMP
data internally as a UNIX timestamp
with microsecond precision.
SELECT SEC_TO_TIMESTAMP(date) FROM ...
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