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

# RecodeMonth

The **RecodeMonth** function replaces the month for the specified **TDateTime** value.

The function converts the date/time value specified by **AValue**, with the value obtained by changing the month within **AValue** to the month specified with **AMonth**.

Valid accepted values for **AMonth** range from 1 to 12.

If the value provided for **AMonth** does not represent a valid month and is not within the allowable range, or if the change results in an invalid day of the month such as changing Jan 31 to Feb 31, then **RecodeMonth** raises an exception.

**Declaration**: Function RecodeMonth(const AValue: TDateTime; const AMonth: 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 2024-07-25
  Value := RecodeMonth(Date, 7);
end;
```
