1. Calculation functions
  2. All Functions
  3. Time and Date Functions
  4. YEAR

Converts a date or a time period to a year in Number format.

The date format depends on your browser settings.

Syntax

YEAR(Value to convert[, Time period method]) 
Argument Data type Description
Value to convert (required) Date, time period The date or time period to convert to a year as a number.
Time period method (optional) Keyword Determines which date in a time period to extract the year from.

Returns

The YEAR function returns a number-formatted result.

Arguments

The Value to convert argument can refer to a line item, property, or expression. This means that you can also use explicit time references such as Time.‘Q2 FY20’ or Time.‘FY20’.

You can only use the Time period method argument if the Value to convert argument is time period-formatted or an explicit time reference. The keywords for the Time period method argument are:

  • START (default): returns the year for the first date in the time period
  • MID: returns the year for the day in the middle of the time period
  • END: returns the year for the last date in the time period

Constraints

The function has these constraints:

  • The Value to convert argument must be date- or time period-formatted.
  • The result must be number-formatted.

Excel equivalent

Examples

In this example, the source line item, Product Date, is date-formatted. The result line item, Product Year, is number-formatted. The function converts the dates to numbers that represent the relevant year.

YEAR (Product Date)

In this example, the source line item, Year Period, is time period-formatted. The result line item, Year Number, is number-formatted. The function converts the time periods to numbers that represent the year.

YEAR(Year Period)       

This example uses an explicit time reference, TIME.'Apr 16', instead of a line item, for the Value to convert argument. The result line item, Year Number Abs, is number-formatted. The function returns the year for TIME.'Apr 16' as a number.

YEAR(TIME.'Apr 16')        

In this example, the source line item, Start of fiscal year, is time period-formatted. The result line items are YEAR STARTYEAR MID, and YEAR END. They use the START, MID, and END keywords for the Time period method argument. This returns the year as a number for the start, middle, and end dates of the week period. As the week spans two calendar years, the START keyword returns a different result to the MID and END keywords.

A module named YEAR keywords that demonstrates the effect of the START, MID, and END keywords.

Similar functions