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 Google Big Query to count the number of zeros in a given dataset?
- How can I use Google BigQuery to create a pivot table?
- How do I set up a Google Big Query zone?
- How do I use Google Big Query with Zoom?
- How do I use Google Big Query to zip files?
- ¿Cuáles son las ventajas y desventajas de usar Google BigQuery?
- How can I use Google BigQuery to retrieve data from a specific year?
- How do I use the YEAR function in Google BigQuery?
- How can I use Google BigQuery on a Windows system?
- How can I use Google BigQuery to answer specific questions?
See more codes...