Files
IronCalc/docs/src/functions/date_and_time/year.md
2025-01-02 18:19:43 +01:00

2.7 KiB

layout, outline, lang
layout outline lang
doc deep en-US

YEAR function

::: warning Note: This draft page is under construction 🚧 :::

Overview

YEAR is a function of the Date and Time category that extracts the year from a valid date serial number, returning a number in the range [1899, 9999].

Usage

Syntax

YEAR(date) => year

Argument descriptions

  • date (number, required). The date for which the year is to be calculated, expressed as a serial number in the range [1, 2958466). The value 1 corresponds to the date 1899-12-31, while 2958465 corresponds to 9999-12-31.

Additional guidance

If the supplied date argument has a fractional part, YEAR uses its floor value.

Returned value

YEAR returns an integer number in the range [1899, 9999], that is the year according to the Gregorian calendar.

Error conditions

  • In common with many other IronCalc functions, YEAR propagates errors that are found in its argument.
  • If no argument, or more than one argument, is supplied, then YEAR returns the #ERROR! error.
  • If the value of the date argument is not (or cannot be converted to) a number, then YEAR returns the #VALUE! error.
  • For some argument values, YEAR may return the #DIV/0! error.
  • If date is less than 1, or greater than or equal to 2,958,466, then YEAR returns the #NUM! error.
  • At present, YEAR does not accept a string representation of a date literal as an argument. For example, the formula =YEAR("2024-12-31") returns the #VALUE! error.

Details

IronCalc utilizes Rust's chrono crate to implement the YEAR function.

Examples

See some examples in IronCalc.