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

# DayOfTheYear

**DayOfTheYear** returns the number of days between a specified **TDateTime** value and 31st December of the previous year, as specified by **AValue**.

You would use this function **DayOfTheYear** to obtain the ordinal position of day within its year.

A **TDateTime** value that refers to 1st January generates a result of 1; 2nd January returns a 2; 1st February returns 32, e.t.c.

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

A code example follows.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  TheDay : word;
begin
 //If YESTERDAY is 28-11-2023 then the result is 332
  TheDay := DayOfTheYear(Yesterday);
  LogInfo('The number of days since 31st Dec are '+IntToStr(TheDay));
end;
```
