9951 explained code solutions for 126 technologies

google-big-queryHow can I format a date in Google Big Query?

Google Big Query supports the Standard SQL dialect and provides a DATE_FORMAT function to format dates. The function takes two arguments: the date to format and the format string. The format string uses the same syntax as the strftime function in the C language.


Output example


The code above will format the current date in the format YYYY-MM-DD.

The parts of the code are:

  • SELECT: This is a SQL keyword to indicate that the query will return a result.
  • DATE_FORMAT: This is the function that formats the date.
  • CURRENT_DATE(): This is a built-in function that returns the current date.
  • %Y-%m-%d: This is the format string to output the date in the format YYYY-MM-DD.

For more information on formatting dates in Google Big Query, see the documentation.

Edit this code on GitHub