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

# EncodeDateDay

**EncodeDateDay** returns a **TDateTime** that represents a specified day ADayOfYear, in a specified year **AYear**.

The time portion of the return value is 00:00:00 - midnight at the start of the specified day **ADayOfYear**.

The definitions for **AWeekOfYear** and **ADayOfWeek** follow the ISO 8601 standard.

* **AYear** is the year which can be any value from 1 through 9999 inclusive.
* **ADayOfYear** is the day of the year, where 1st January is day 1, 2nd January is day 2, 1st February is day 32 e.t.c.

If **AYear** is not within range, **ADayOfYear** is less than 1 or greater than the number of days in **AYear**, **EncodeDateDay** will raise an error.

**Declaration**: function EncodeDateDay(const AYear, ADayOfYear: Word): TDateTime;

```pascal
procedure OnMapEvent(var Value:Variant);
var
  aYear, aDay : word;
begin
  aYear := 2024;
  aDay := 301;

 //Create a date/time from its separate parts - returns 27-10-2024
  LogInfo(FormatDateTime('dd-mm-yyyy hh:nn:ss.zzz',EncodeDateDay(aYear, aDay)));
  LogInfo('');

end;
```
