---
url: >-
  /statelake/scripting-reference/functions-and-procedures/datetime-functions/recodeyear.md
---

# RecodeYear

The **RecodeYear** function replaces the year for the specified **TDateTime** value.

The function converts the date/time value specified by **AValue**, with the value obtained by changing the year to **AYear**.

Accepted values for **AYear** range from 1 to 9999.

If the value provided for **AYear** is not within the allowable range, or if the change results in an invalid day of the month such as changing Feb 29 on a leap year to a non-leap year, then **RecodeYear** raises an exception.

**Declaration**: Function RecodeYear(const AValue: TDateTime; const AYear: Word): TDateTime;

An example would be as follows.

```pascal
procedure OnMapEvent(var Value:Variant);
begin
 //If Date is 2024-06-25 then the result is 2026-06-25
  Value := RecodeYear(Date, 2026);
end;
```
