{"record":{"id":"824aa4000a44e2b4","repo":"n8n-io/n8n","slug":"isbetween-expected-exactly-two-args","errorCode":null,"errorMessage":"isBetween(): expected exactly two args","messagePattern":"isBetween\\(\\): expected exactly two args","errorType":"exception","errorClass":"ExpressionExtensionError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/expression-runtime/src/extensions/date-extensions.ts","lineNumber":151,"sourceCode":"\tif (isDateTime(date)) return date.get(unit);\n\n\treturn DateTime.fromJSDate(date).get(unit);\n}\n\nfunction format(date: Date | DateTime, extraArgs: unknown[]): string {\n\tconst [dateFormat, localeOpts = {}] = extraArgs as [string, LocaleOptions];\n\tif (isDateTime(date)) {\n\t\treturn date.toFormat(dateFormat, { ...localeOpts });\n\t}\n\treturn DateTime.fromJSDate(date).toFormat(dateFormat, { ...localeOpts });\n}\n\nfunction isBetween(\n\tdate: Date | DateTime,\n\textraArgs: Array<string | Date | DateTime>,\n): boolean | undefined {\n\tif (extraArgs.length !== 2) {\n\t\tthrow new ExpressionExtensionError('isBetween(): expected exactly two args');\n\t}\n\n\tconst [first, second] = extraArgs;\n\n\tconst firstDate = convertToDateTime(first);\n\tconst secondDate = convertToDateTime(second);\n\n\tif (!firstDate || !secondDate) {\n\t\treturn;\n\t}\n\n\tif (firstDate > secondDate) {\n\t\treturn secondDate < date && date < firstDate;\n\t}\n\treturn secondDate > date && date > firstDate;\n}\n\nfunction isDst(date: Date | DateTime): boolean {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/expression-runtime/src/extensions/date-extensions.ts#L133-L169","documentation":"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.","triggerScenarios":"Calling with a single bound: `.isBetween($json.start)`; with three: `.isBetween(a, b, c)`; or with none.","commonSituations":"Copying from `.isAfter()` / `.isBefore()` which take one argument; an optional second bound that was omitted because upstream data was missing.","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."],"exampleFix":"// before\n{{ $json.now.isBetween($json.start) }}\n// after\n{{ $json.now.isBetween($json.start, $json.end) }}","handlingStrategy":"validation","validationCode":"// Ensure both bounds are present and date-like before the expression:\nconst { start, end } = $json;\nif (start == null || end == null) {\n  throw new Error('isBetween(): both start and end are required');\n}\nreturn $json;","typeGuard":"const isDateLike = (v: unknown): v is string | Date =>\n  typeof v === 'string' || (v instanceof Date) || (v != null && typeof v === 'object' && 'toISO' in v);","tryCatchPattern":null,"preventionTips":["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."],"tags":["expression","date","arguments","argument-count"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}