Format date google-bigquery as mm / dd / yyyy in query results

I am using Bigquery SQL to create a report. Bigquery's default date format is yyyy-mm-dd, but I want it to be formatted as mm / dd / yyyy.

Is there a way using Bigquery SQL to convert a date format to SELECT?

Thanks in advance,

+5
source share
1 answer

In BigQuery Legacy SQL

SELECT STRFTIME_UTC_USEC("2016-10-20", "%m/%d/%Y"), STRFTIME_UTC_USEC(CURRENT_DATE(), "%m/%d/%Y") 

In BigQuery Standard SQL (see Enabling Standard SQL )

 SELECT FORMAT_DATE("%m/%d/%Y", DATE "2016-10-20"), FORMAT_DATE("%m/%d/%Y", CURRENT_DATE()) 

Also Migrating from Legacy SQL

+12
source

Source: https://habr.com/ru/post/1258545/


All Articles