Skip to main content

InvalidDateMonthWeekError

Procedure InvalidDateMonthWeekError(const AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word)

Example

procedure ScriptEvent(var Value: variant);
begin
try
InvalidDateMonthWeekError(2026, 2, 5, 1);
except
Value := 'Invalid date fields were rejected';
end;
end;

Usage

InvalidDateMonthWeekError raises the DateUtils invalid month-week conversion error for supplied ISO month-week fields.

Parameters

NameTypeDescription
AYearWord, constYear value included in the formatted error.
AMonthWord, constMonth value included in the formatted error.
AWeekOfMonthWord, constWeek-within-month value included in the formatted error.
ADayOfWeekWord, constMonday-based weekday value included in the formatted error.

Behaviour

  • The procedure never returns normally.
  • Use IsValidDateMonthWeek when the script needs a Boolean range check rather than an exception.

Important usage notes

  • The routine formats the supplied fields; it does not prove that the requested nth weekday exists in that month. Even completely valid-looking fields still cause the exception.
  • The parameters are Word values, so negative numbers cannot be represented by the declared interface.

Errors

The intended and unconditional result is an EConvertError. The human-readable resource text can vary with the Velox runtime language or version; do not parse that message as a stable machine interface.

Usage notes

These DateUtils error helpers are principally useful to library code that has already detected invalid fields and wants the standard conversion error. Ordinary Velox scripts should normally validate first and provide business-specific handling rather than invoke this procedure directly.

Additional Technical Info

InvalidDateMonthWeekError deliberately raises the DateUtils conversion exception for an invalid year, month, week-within-month and weekday. It is an error-construction helper, not a validator.

The example is fictional and source-reviewed. It catches the deliberately raised exception so that the surrounding flow can continue; it was not executed by the documentation workflow.

Implementation

The DateUtils import binds directly to Delphi 37.0 System.DateUtils.InvalidDateMonthWeekError. The procedure formats the applicable DateUtils resource string with the supplied numeric fields and immediately raises an EConvertError.

Side effects

Control leaves the current statement by exception. There is no external I/O or persistent mutation.

Performance and concurrency

Formatting and raising one exception is constant-time but substantially more expensive than returning a Boolean. The routine has no mutable state of its own; resource and formatting behaviour is supplied by the host runtime.

Related entries

External references

Created 2026-07-15