Tom Azernour avatar
Written by Tom Azernour
Updated over a week ago

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 to 31556952

  • YEAR(created_at) returns the year portion for the created_at field value

  • YEAR(DATE(2023, 08, 27)) returns 2023

  • AVG(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 the created_at field value plus 2 years.

Did this answer your question?