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

# EndOfAYear

**EndOfAYear** returns a **TDateTime** value that represents the last millisecond of the last day of the year, by returning the last expressible moment of the same year specified by **AYear**.

**Declaration**: Function EndOfAYear( const AYear : Word) : TDateTime;

An example follows and with a processing date of 2023, returns 31/12/2023 23:59:59.999.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  TheYear : word;
  TheDate : TDateTime;
begin
 TheYear := 2023;
 TheDate := EndOfAYear(TheYear);
 LogInfo('The end of the year date is '+FormatDateTime('dd/mm/yyyy hh:nn:ss',TheDate));
end;
```
