n8n-io/n8n · error · ExpressionExtensionError
isBetween(): expected exactly two args
Error message
isBetween(): expected exactly two args
What it means
The `.isBetween(a, b)` date extension checks whether the source date lies between two bounds. It throws when `extraArgs.length !== 2` because the body destructures exactly two values into `firstDate`/`secondDate`. Any other argument count is rejected up front.
Source
Thrown at packages/@n8n/expression-runtime/src/extensions/date-extensions.ts:151
if (isDateTime(date)) return date.get(unit);
return DateTime.fromJSDate(date).get(unit);
}
function format(date: Date | DateTime, extraArgs: unknown[]): string {
const [dateFormat, localeOpts = {}] = extraArgs as [string, LocaleOptions];
if (isDateTime(date)) {
return date.toFormat(dateFormat, { ...localeOpts });
}
return DateTime.fromJSDate(date).toFormat(dateFormat, { ...localeOpts });
}
function isBetween(
date: Date | DateTime,
extraArgs: Array<string | Date | DateTime>,
): boolean | undefined {
if (extraArgs.length !== 2) {
throw new ExpressionExtensionError('isBetween(): expected exactly two args');
}
const [first, second] = extraArgs;
const firstDate = convertToDateTime(first);
const secondDate = convertToDateTime(second);
if (!firstDate || !secondDate) {
return;
}
if (firstDate > secondDate) {
return secondDate < date && date < firstDate;
}
return secondDate > date && date > firstDate;
}
function isDst(date: Date | DateTime): boolean {View on GitHub (pinned to 5ac6606e81)
Solutions
- Supply exactly two date-typed arguments: `.isBetween($json.start, $json.end)`.
- If you only need a one-sided comparison, switch to `.isAfter()` or `.isBefore()`.
- Coerce bound arguments with `.toDateTime()` if they arrive as strings.
Example fix
// before
{{ $json.now.isBetween($json.start) }}
// after
{{ $json.now.isBetween($json.start, $json.end) }} Defensive patterns
Strategy: validation
Validate before calling
// Ensure both bounds are present and date-like before the expression:
const { start, end } = $json;
if (start == null || end == null) {
throw new Error('isBetween(): both start and end are required');
}
return $json; Type guard
const isDateLike = (v: unknown): v is string | Date => typeof v === 'string' || (v instanceof Date) || (v != null && typeof v === 'object' && 'toISO' in v);
Prevention
- Count the arguments inside the parentheses — `.isBetween` needs exactly two.
- Coerce bound arguments with `.toDateTime()` when they may arrive as strings.
- Use `.isAfter()` / `.isBefore()` for one-sided comparisons.
When it happens
Trigger: Calling with a single bound: `.isBetween($json.start)`; with three: `.isBetween(a, b, c)`; or with none.
Common situations: Copying from `.isAfter()` / `.isBefore()` which take one argument; an optional second bound that was omitted because upstream data was missing.
Related errors
- expected two arguments (value, defaultValue) for this functi
- Unsupported unit '${String(errorUnit)}'. Supported: ${durati
- Unsupported format '${String(valueFormat)}'. toDateTime() su
- Value is not a valid date
- cannot convert to date
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/824aa4000a44e2b4.
Report an issue: GitHub.