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

# DecodeDateMonthWeek

**DecodeDateMonthWeek** pulls apart the specified date **AValue**, and returns the date broken into its various component parts.

The parameters **AYear**, **AMonth**, **AWeekOfMonth**, and **ADayOfWeek** are populated with the parts of the date, so that you can then use the variables in your calculations.

This is the opposite of **EncodeDateMonthWeek** [EncodeDateMonthWeek](/statelake/scripting-reference/functions-and-procedures/datetime-functions/encodedatemonthweek).

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

* **AValue** is the **TDateTime** value to be de-constructed.
* **AYear** returns the year that **AValue** represents.
* **AMonth** returns the month value that is represented by **AValue**.
* **AWeekOfMonth** returns the week within **AYear** that **AValue** represents, where 1 is the first week with four or more days.
* **ADayOfWeek** returns the day within **AWeekOfMonth** that **AValue** represents, where 1 is Monday and 7 is Sunday.

**Declaration**: procedure DecodeDateMonthWeek(const AValue: TDateTime; out AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word);

Such as the example below.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  aYear, aMonth, aWeek, aDay : word;
begin
 //Break date/time into its individual parts
  DecodeDateMonthWeek(Now, aYear, aMonth, aWeek, aDay);

 if ((aWeek=3) and (aDay=7)) then

    ...do something at this special time...;

end;
```
