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
- How can I use IFNULL in Google BigQuery?
- How can I use Google Big Query to count the number of zeros in a given dataset?
- How do Google BigQuery and Azure compare in terms of performance and cost?
- How do I use Google BigQuery indexes to optimize my queries?
- How can I calculate the cost of using Google BigQuery?
- How do I set up a Google Big Query zone?
- How do I use Google Big Query with Excel?
- How do I use Google BigQuery language to query data?
- How do I use the YEAR function in Google BigQuery?
- ¿Cuáles son las ventajas y desventajas de usar Google BigQuery?
See more codes...