Skip to main content

InvalidDayOfWeekInMonthError

Procedure InvalidDayOfWeekInMonthError(const AYear, AMonth, ANthDayOfWeek, ADayOfWeek: Word)

Example

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

Usage

InvalidDayOfWeekInMonthError raises the DateUtils invalid nth-weekday-in-month conversion error for supplied calendar fields.

Parameters

NameTypeDescription
AYearWord, constCalendar year included in the formatted error.
AMonthWord, constCalendar month included in the formatted error.
ANthDayOfWeekWord, constRequested occurrence number included in the formatted error.
ADayOfWeekWord, constRequested weekday number 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 does not calculate whether an occurrence exists and does not conditionally raise. Its only operation is to construct and raise the error.
  • 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

InvalidDayOfWeekInMonthError deliberately raises the DateUtils conversion exception for an invalid year, month, nth occurrence 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.InvalidDayOfWeekInMonthError. 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