YEAR
Returns the year of a given date.
Sample usage
YEAR(Date)
Syntax
The following syntax returns the year from a Date value.
YEAR(date_expression )
The following syntax returns the year from a compatibility mode Date value.
YEAR(X [,format_string ])
Parameters
date_expression- a Date or Date & Time field or expression.X- a field or expression that evaluates to Text, Number, or compatibility mode Date.format_string- format forX. Optional ifXis correctly configured as a semantic date field.
Format strings for compatibility mode dates
Supported date functions accept the following input formats ifX is a Text field or expression, or compatibility mode Date:
BASIC: %Y/%m/%d-%H:%M:%SDEFAULT_DASH: %Y-%m-%d [%H:%M:%S]DEFAULT_SLASH: %Y/%m/%d [%H:%M:%S]DEFAULT_DECIMAL: %Y%m%d [%H:%M:%S]RFC_1123: for example, Sat, 24 May 2008 20:09:47 GMTRFC_3339: for example, 2008-05-24T20:09:47ZDECIMAL_DATE: same asDEFAULT_DECIMAL
Any validstrptime format is accepted.
Supported time functions accept the following input format ifX is a Number field or expression:
SECONDS: seconds since EpochMILLIS: milliseconds since EpochMICROS: microseconds since EpochNANOS: nanoseconds since EpochJULIAN_DATE: days since Epoch
Examples
| Example formula | Input | Output |
|---|---|---|
YEAR(Date) | Jan 1, 2019 | 2019 |
YEAR(Date as Text, 'BASIC') | 2019/01/01-09:40:45 | 2019 |
YEAR(Date as Number, 'SECONDS') | 1561784874 | 2019 |
| 1562004058620 | 2019 |
Notes
This function works with both compatibility mode dates andupgraded Date and Date & Time data types.
Related resources
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.