Extract Month and Year from timestamp in BigQuery using SQL EXTRACT, YEAR, MONTH, CONCAT, CAST, LPAD
Discovered: Aug 8, 2024 00:29 Extract Month and Year from timestamp in Bigquery - Stack Overflow <– QUOTE: Answering the title of the question as probably others will end up here like me looking for a way to create a YYYYMM year-month from a BigQuery timestamp. ... This is the code I ended up with in standard SQL:
CONCAT(\
CAST(EXTRACT(YEAR from timestamp) as string), \
LPAD(CAST(EXTRACT(MONTH from timestamp) asstring),2,'0')) \
AS yearmonth
^^– I’ll probably need this Eines Tages!