Skip to content

Commit

Permalink
Add YEAR function description
Browse files Browse the repository at this point in the history
  • Loading branch information
stevethesleeve authored and nhatcher committed Jan 2, 2025
1 parent f63d307 commit 02e726b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/src/functions/date-and-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir
| WEEKNUM | <Badge type="info" text="Not implemented yet" /> ||
| WORKDAY | <Badge type="info" text="Not implemented yet" /> ||
| WORKDAY.INTL | <Badge type="info" text="Not implemented yet" /> ||
| YEAR | <Badge type="tip" text="Available" /> | |
| YEAR | <Badge type="tip" text="Available" /> | [YEAR](date_and_time/year) |
| YEARFRAC | <Badge type="info" text="Not implemented yet" /> ||
36 changes: 31 additions & 5 deletions docs/src/functions/date_and_time/year.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,35 @@ layout: doc
outline: deep
lang: en-US
---

# YEAR

# YEAR function
::: warning
🚧 This function is implemented but currently lacks detailed documentation. For guidance, you may refer to the equivalent functionality in [Microsoft Excel documentation](https://support.microsoft.com/en-us/office/excel-functions-by-category-5f91f4e9-7b42-46d2-9bd1-63f26a86c0eb).
:::
**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](/features/serial-numbers.md), returning a number in the range [1899, 9999].
## Usage
### Syntax
**YEAR(<span title="Number" style="color:#1E88E5">date</span>) => <span title="Number" style="color:#1E88E5">year</span>**
### Argument descriptions
* *date* ([number](/features/value-types#numbers), required). The date for which the year is to be calculated, expressed as a [serial number](/features/serial-numbers.md) 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](https://en.wikipedia.org/wiki/Floor_and_ceiling_functions).
### Returned value
YEAR returns an integer [number](/features/value-types#numbers) in the range [1899, 9999], that is the year according to the [Gregorian calendar](https://en.wikipedia.org/wiki/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!`](/features/error-types.md#error) error.
* If the value of the *date* argument is not (or cannot be converted to) a [number](/features/value-types#numbers), then YEAR returns the [`#VALUE!`](/features/error-types.md#value) error.
* For some argument values, YEAR may return the [`#DIV/0!`](/features/error-types.md#div-0) error.
* If date is less than 0, or greater than or equal to 2,958,466, then YEAR returns the [`#NUM!`](/features/error-types.md#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!`](/features/error-types.md#value) error.
<!--@include: ../markdown-snippets/error-type-details.txt-->
## Details
IronCalc utilizes Rust's [chrono](https://docs.rs/chrono/latest/chrono/) crate to implement the YEAR function.
## Examples
[See some examples in IronCalc](https://app.ironcalc.com/?example=year).

## Links
* See also IronCalc's [DAY](/functions/date_and_time/day.md) and [MONTH](/functions/date_and_time/month.md) functions.
* Visit Microsoft Excel's [YEAR function](https://support.microsoft.com/en-gb/office/year-function-c64f017a-1354-490d-981f-578e8ec8d3b9) page.
* Both [Google Sheets](https://support.google.com/docs/answer/3093061) and [LibreOffice Calc](https://wiki.documentfoundation.org/Documentation/Calc_Functions/YEAR) provide versions of the YEAR function.
Binary file modified xlsx/tests/docs/YEAR.xlsx
Binary file not shown.

0 comments on commit 02e726b

Please sign in to comment.