pentaho/pentaho-kettle · error · RuntimeException
The function call dateDiff requires 3 arguments.
Error message
The function call dateDiff requires 3 arguments.
What it means
dateDiff requires exactly three arguments — the date-part unit string and two dates. With any other argument count it throws this RuntimeException rather than guessing which unit or dates the caller meant.
Solutions
- Call with exactly three arguments: dateDiff('d', date1, date2).
- Confirm the unit string is the first argument.
- Check the Script step function reference for the documented signature.
Example fix
// before
var diff = dateDiff(date1, date2);
// after
var diff = dateDiff('d', date1, date2); Defensive patterns
Strategy: validation
Validate before calling
if (unit && d1 instanceof Date && d2 instanceof Date) { var diff = dateDiff(unit, d1, d2); } Type guard
function canDateDiff(u, a, b) { return typeof u === 'string' && a instanceof Date && b instanceof Date; } Try / catch
try { var diff = dateDiff(unit, d1, d2); } catch (e) { if (/dateDiff requires 3 arguments/.test(String(e))) { diff = null; } else { throw e; } } Prevention
- Always supply the unit string as the first argument.
- Call with exactly three arguments.
- Check the signature when porting scripts between environments.
When it happens
Trigger: Calling dateDiff with fewer than three arguments (e.g. omitting the unit) or more than three from script code.
Common situations: Forgetting the unit argument after refactoring; passing extra arguments expecting them to be ignored; confusion with language-specific dateDiff variants with different signatures.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- The function call fireToDB requires 2 arguments.
- The function call floor requires 1 argument.
- The function call getDayNumber requires 2 arguments.
- The function call getEnvironmentVar requires 1 argument.
- The function call isWorkingDay requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/ff793e24e53c3ff0.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:607
return new Double( iDays / 7 );
} else if ( strType.equals( "ss" ) ) {
return new Double( ( ( endL - startL ) / 1000 ) );
} else if ( strType.equals( "mi" ) ) {
return new Double( ( ( endL - startL ) / 60000 ) );
} else if ( strType.equals( "hh" ) ) {
return new Double( ( ( endL - startL ) / 3600000 ) );
} else {
return new Double( ( ( endL - startL ) / 86400000 ) );
}
/*
* End Bugfix
*/
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
} else {
throw new RuntimeException( "The function call dateDiff requires 3 arguments." );
}
}
public static Object getNextWorkingDay( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
// (Date dIn){
if ( ArgList.length == 1 ) {
try {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return undefinedValue;
}
java.util.Date dIn = (java.util.Date) ArgList[0];
Calendar startDate = Calendar.getInstance();
startDate.setTime( dIn );
startDate.add( Calendar.DATE, 1 );
while ( startDate.get( Calendar.DAY_OF_WEEK ) == Calendar.SATURDAYView on GitHub (pinned to f3058517a1)