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

# RecodeMilliSecond

The **RecodeMilliSecond** function replaces the miliseconds for the specified **TDateTime** value.

The function converts the date/time **TDateTime** value specified by **AValue**, with the value obtained by changing the milliseconds of the seconds within **AValue**, to the milliseconds specified with **AMilliSecond**.

Valid accepted values for **AMilliSecond** range from 0 to 999.

If the value provided for **AMilliSecond** is not within the allowable range, then **RecodeMilliSecond** raises an exception error.

**Declaration**: Function RecodeMilliSecond(const AValue: TDateTime; const AMilliSecond: Word): TDateTime;

An example would be as follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  ThatDate : TDateTime;
begin
 //Forces the millisecond of the minute to 500 regardless of any other parameter
 ThatDate := RecodeMilliSecond(Now, 500);
 LogInfo(FormatDateTime('dd-mm-yyyy hh:nn:ss.zzz', ThatDate));

end;
```
