Type: Function
Function: YEAR
Syntax: YEAR([datetime])
Description: This function has two different modes of operation, based on whether an argument is provided or not. With no arguments, it returns the standard duration of a year in seconds (2629746, which is based on 365 days). With a datetime argument, it returns the year portion for the provided datetime
Sample usage:
YEAR()is equal to31556952YEAR(created_at)returns the year portion for thecreated_atfield valueYEAR(DATE(2023, 08, 27))returns2023AVG(closed_at-created_at)/YEAR()returns the time elapsed in years between the creation and closing of a record. Note that the difference between two dates (closed_at-created_at) is always returned in seconds.created_at + 2*YEAR()returns thecreated_atfield value plus 2 years.
