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

# StartOfTheWeek

The **StartOfTheWeek** function returns a **TDateTime** date value that represents 12:00:00:00 A.M. on the first day of the week identified by the given date parameter **AValue**.

**StartOfTheWeek** returns the first expressible moment of the same week specified by **AValue**, by replacing the time portion of **AValue** with 00:00:00, and changing the day to Monday.

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

**Declaration**: Function StartOfTheWeek(const AValue: TDateTime): TDateTime;

An example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  TheDate : TDateTime;
begin
 //Processing date is 29/11/2023, so the return value is 27/11/2023 00:00:00
  TheDate := StartOfTheWeek(Date);
  LogInfo('The start of the week date is '+FormatDateTime('dd/mm/yyyy hh:nn:ss',TheDate));
end;
```
