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

# IsValidDateWeek

**IsValidDateWeek** returns **True** if the given year, week and day of the year represent components of a valid date.

* **AYear** must be within the range of 1 through 9999 inclusive.
* **AWeekOfYear** must fall within the range of 1 through to the number of weeks in the specified year - i.e. such as 52 weeks,
* **ADayOfWeek** must fall within the range of 1 through to 7 - day 1 being Monday and day 7 being Sunday.

Declaration: Function IsValidDateWeek(const AYear, AWeekOfYear, ADayOfWeek: Word): Boolean;

An example of its use follows.

```pascal
procedure ScriptEvent(var Value:Variant);
var
  TheYear, TheDay, TheWeek : word;
begin
 //Returns true if the given YEAR, WEEK and DAY are valid date components

 //VALID parts
  TheDay := 6;
  TheWeek := 48;
  TheYear := 2023;
 If IsValidDateWeek(TheYear, TheWeek, TheDay) then
    Loginfo('YAHOO!!! The WEEK date is valid.')
 else
    LogInfo('OOPS!! The WEEK date is not valid.');

 //INVALID parts . ... there are not 8 days in a week!
 //This will fail if any of these parts are FALSE
  TheDay := 8;
  TheWeek := 48;
  TheYear := 2023;
 If IsValidDateWeek(TheYear, TheWeek, TheDay) then
    Loginfo('YAHOO!!! The WEEK date is valid.')
 else
    LogInfo('OOPS!! The WEEK date is not valid.');

  LogInfo('');
end;
```
