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

# RecodeHour

The **RecodeHour** function replaces the hour for the specified **TDateTime** value.

The function converts the date/time **TDateTime** value specified by **AValue**, with the value obtained by changing the hour of the day within **AValue** to the hour specified with **AHour**.

Valid accepted values for **AHour** range from 0 to 24. If **AHour** is 24, then the values for the minutes, seconds, and milliseconds must all equal zero (0).

If the value provided for **AHour** is not within the allowable range so it does not represent a valid hour, then **RecodeHour** raises an exception error.

**Declaration**: Function RecodeHour(const AValue: TDateTime; const AHour: Word): TDateTime;

An example would be as follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  ThatDate : TDateTime;
begin
 //Resets the hour of the day to 12 midday
 ThatDate := RecodeHour(Now, 12);
 LogInfo(FormatDateTime('dd-mm-yyyy hh:nn:ss.zzz', ThatDate));

end;
```
