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 analyze Reddit data?
- How do I set up permissions for Google BigQuery?
- How do I use wildcards in Google BigQuery?
- How do I use a JSON service account with Google Big Query?
- How do I rename a column in Google BigQuery?
- How do I use the UNION clause in Google BigQuery?
- How do I integrate Tableau with Google BigQuery?
- How do I use Google BigQuery Sandbox?
- What are the advantages and disadvantages of using Google BigQuery?
- How can I use Google BigQuery on a Windows system?
See more codes...