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.
SELECT DATE_FORMAT(CURRENT_DATE(), '%Y-%m-%d')
Output example
2020-07-01
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 formatYYYY-MM-DD.
For more information on formatting dates in Google Big Query, see the documentation.
More of Google Big Query
- ¿Cuáles son las ventajas y desventajas de usar Google BigQuery?
- How do I set up a Google Big Query zone?
- How can I use Google Big Query to integrate with Zephyr?
- How do I use a JSON service account with Google Big Query?
- How do I use Google Big Query with Zoom?
- How do I use Google Big Query to zip files?
- How do I create and use a user-defined function (UDF) in Google BigQuery?
- How can I use Google Big Query to count the number of zeros in a given dataset?
- How can I use Google BigQuery to wait for a query to complete?
- How do I query Google BigQuery using XML?
See more codes...