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

# MilliSecondOfTheWeek

**MilliSecondOfTheWeek** returns the number of milliseconds between the **TDateTime** value entered as **AValue**, and 12:00 A.M. of the first day of the week that is specified by **AValue**.

**MilliSecondOfTheWeek** defines the week of **AValue** according to the ISO 8601 standard, where the week starts on Monday and ends on Sunday.

This could return a very large number.

**Declaration**: Function MilliSecondOfTheWeek(const AValue: TDateTime): Cardinal;

A simple example follows.

```pascal
procedure ScriptEvent (var Value : variant);
var
  TheSec : cardinal;
  TheDate : TDateTime;
begin
 //The result is 51915650
  TheDate := EncodeDateTime(2023, 11, 27, 14, 25, 15, 650);
  TheSec := MilliSecondOfTheWeek(TheDate);
  LogInfo('The number of milliseconds since the beginning of the week is '+IntToStr(TheSec));

 //The result is 307515650
  TheDate := EncodeDateTime(2023, 11, 30, 13, 25, 15, 650);
  TheSec := MilliSecondOfTheWeek(TheDate);
  LogInfo('The number of milliseconds since the beginning of the week is '+IntToStr(TheSec));
end;
```
