sqlgoogle-bigquery

How do I cast a timestamp column as a MM/DD/YYYY in BigQuery


I'm trying to cast the results of an entire column in BigQuery in MM/DD/YYYY format

Time_Column
2022-05-26T17:32:41.000Z
2022-05-28T06:34:23.000Z

Results: enter image description here


Solution

  • We can try to use FORMAT_DATE function to make it, we can refer to this link Supported Format Elements For DATE to use your expected date format from the datetime type.

    SELECT FORMAT_DATE("%m/%d/%Y", Time_Column) 
    FROM T