YEAR() extracts the year component from a date expression and returns it as a numeric value. This function is useful for date-based filtering, grouping, and analysis. If a null date is provided, YEAR() returns zero. The function works with various date formats and is commonly used in conjunction with other date functions.
YEAR(date)
YEAR() returns an integer
// Basic year extraction
YEAR(DATE("11/03/2007")) = 2007
// Year from date components
YEAR(DATE(2007, 12, 25)) = 2007
// Additional examples
YEAR(DATE(2024, 1, 1)) = 2024 // Start of year
YEAR(DATE(2024, 12, 31)) = 2024 // End of year
YEAR(NULL) = 0 // Null date handling
YEAR(DATE(2000, 2, 29)) = 2000 // Leap year