Home > OS >  Combine "Year", "Month", and "Day" columns in Biqquery to a Date colum
Combine "Year", "Month", and "Day" columns in Biqquery to a Date colum

Time:07-22

I am new to the bigquery. I was looking into the public dataset gsod, which has three different columns, i.e., year, month, and day. Can I change this to a single column called date in format yyyy-mm-dd?

I saw you could do something like

SELECT
  DATE(2016, 12, 25) AS date_ymd

But how do I pass columns inside DATE instead of a single value? I want to combine the query with the following simple query and get a column called date.

SELECT
*,
FROM `bigquery-public-data.samples.gsod`

CodePudding user response:

Use below

SELECT date(year, month, day) as date_ymd, *
FROM `bigquery-public-data.samples.gsod` 
  • Related