Unix time to datetime in google bigquery?

I'm trying to transfer a postgres query to Google BigQuery but I can't seem to find out how to transfer this part:

\n\n
date_trunc('Month',to_timestamp(created_utc)) \n
\n\n

Solution:

Below is for BigQuery Standard SQL

\n\n
DATE_TRUNC(DATE(TIMESTAMP_SECONDS(created_utc)), MONTH)\n
\n\n

example to test / play with

\n\n
#standardSQL\nSELECT\n  DATE_TRUNC(DATE(TIMESTAMP_SECONDS(created_utc)), MONTH)\nFROM `fh-bigquery.reddit_comments.2017_08`\nLIMIT 5\n

DataFreak

posted on

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds