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

# StartOfTheYear

The **StartOfTheYear** function returns a **TDateTime** value that represents 12:00:00:00 A.M. on the first day of the year, by returning the first expressible moment of the same year as the **TDateTime** specified by **AValue**.

It replaces the time portion of **AValue** with 00:00:00, changes the day to January 1, and returns the result.

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

An example follows and with a processing date of 20/10/2023 10:20:18, returns 01/01/2023 00:00:00.

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