google-big-queryHow do I use the YEAR function in Google BigQuery?
The YEAR function in Google BigQuery is used to extract the year from a date or timestamp expression. It takes in one parameter, which is a date or timestamp expression. The output of the YEAR function is an integer between 1 and 9999.
For example:
SELECT YEAR('2015-06-13') as year;
The output of this query will be:
year
2015
The parts of the code are:
SELECT: This is a keyword used to indicate that a query is being executedYEAR('2015-06-13'): This is the YEAR function, taking in the date '2015-06-13' as a parameteras year: This is an alias for the output of the query, which will be stored in the column 'year'
Helpful links
More of Google Big Query
- How do I set up a Google Big Query zone?
- How can I use Google Big Query to count the number of zeros in a given dataset?
- How do I use a Google BigQuery URL?
- How do I access my Google BigQuery history?
- How do I update data in Google BigQuery?
- How can I use Google Big Query with Udemy?
- How do I create and use a user-defined function (UDF) in Google BigQuery?
- How can I use Google Big Query to store and manage my NoSQL data?
- How can I learn to use Google BigQuery?
- How can I use Google BigQuery ML to build a machine learning model?
See more codes...