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 start using Google Big Query?
- How can I learn to use Google Big Query?
- How can I use the CASE WHEN statement in Google Big Query?
- How can I use Google BigQuery to wait for a query to complete?
- How do I use the UNION clause in Google BigQuery?
- How do I use the YEAR function in Google BigQuery?
- What is Google Big Query?
- How do I use Google BigQuery Sandbox?
- How do Google BigQuery and Azure compare in terms of performance and cost?
See more codes...