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

# StartOfADay

**StartOfADay** returns a **TDateTime** value that represents the first expressible moment of 12:00:00:00 A.M. on a specified day.

* The **AYear** parameter specifies the year of the desired day.
* The **AMonth** and **ADay** parameters specify the desired day as a month of the year and day of the month. **AMonth** can range from 1 through 12. **ADay** can range from 1 through 28, 29, 30, or 31, depending on the values of **AYear** and **AMonth**.

**Declaration**: Function StartOfADay(const AYear, AMonth, ADay: Word): TDateTime;

The example is.

```pascal
procedure ScriptEvent(var Value:Variant);
var
   TheYear, TheMonth, TheDay : word;
   TheDate : TDateTime;
begin
  TheYear := 2023;
  TheMonth := 08;
  TheDay := 3;
  TheDate := StartOfADay(TheYear, TheMonth, TheDay);
 //Returns 03/08/2023 00:00:00
  LogInfo('The start of the day 3rd August 2023 is '+FormatDateTime('dd/mm/yyyy hh:nn:ss',TheDate));
end;
```
