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

# DayOfWeek

**DayOfWeek** returns the day of the week represented by the **TDateTime** value specified by **AValue**.

You would use **DayOfWeek** to obtain the ordinal position of day within its week, where 1 indicates a Sunday, and 7 indicates a Saturday.

::: info
**DayOfWeek** is not ISO 8601 compliant, so Sunday is considered the first day of the week.

To obtain the day of the week, where Monday is considered the first day of the week, use the **DayOfTheWeek** function instead. Please review [DayOfTheWeek](/statelake/scripting-reference/functions-and-procedures/datetime-functions/dayoftheweek).
:::

**Declaration**: function DayOfWeek(const AValue: TDateTime): Word;

A code example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  TheDay : word;
begin
 //If YESTERDAY is 29-11-2023 then the result is 4 (Wednesday)
  TheDay := DayOfWeek(Yesterday);
  LogInfo('The day number for Wednesday 29-11-2023 (Sunday-based) is '+IntToStr(TheDay));
end;
```
