---
url: /flow/guide/scripting-reference/functions/datetime/recodemonth.md
---

# RecodeMonth

## Declaration

`Function RecodeMonth(const AValue: TDateTime; const AMonth: Word): TDateTime`

### Example

```pascal
procedure OnMapEvent(var Value:Variant);
begin
  Value := RecodeMonth(Date, 7); // if Date is 2009-06-25 then result is 2009-07-25
end;
```

## Description

Replaces the month of the year for a specified TDateTime value. Use RecodeMonth to convert the date/time value specified by AValue with the value obtained by changing the month of the year to AMonth. Legal values for AMonth range from 1 to 12.

If the value provided for AMonth does not represent a valid month, or if the change results in an invalid day of the month (for example trying to change Jan 31 to Feb 31), RecodeMonth raises an exception.
