pentaho/pentaho-kettle · error

The function call getDayNumber requires 2 arguments.

Error message

The function call getDayNumber requires 2 arguments.

What it means

Arity guard for getDayNumber: the function needs exactly two arguments — a date and a type string ("y" day-of-year, "m" day-of-month, "w" day-of-week, "wm" day-of-week-in-month). A different count reaches the else-branch and throws.

Solutions

  1. Call with exactly two arguments, e.g. getDayNumber(dateField, 'y').
  2. Pass a Date object (or value convertible to one) as the first argument.
  3. Consult this PDI version's function list for the correct second-argument values.

Example fix

// before
var d = getDayNumber(birthDate);
// after
var d = getDayNumber(birthDate, 'y');
Defensive patterns

Strategy: validation

Validate before calling

var d = dateField instanceof Date ? dateField : str2date(dateField, 'yyyy-MM-dd');
var n = getDayNumber(d, 'y');

Type guard

function isDateArg(v){ return v instanceof Date && !isNaN(v.getTime()); }

Prevention

When it happens

Trigger: getDayNumber(date) with one argument, or three arguments, in a Modified Java Script Value step.

Common situations: Forgetting the type argument ('y','m','d' style selector); passing the date as a string and an extra locale parameter; copy-paste from an older PDI example with a different signature.

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


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/4646a4f3646b364d. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:465

          Calendar startDate = Calendar.getInstance();
          startDate.setTime( dIn );
          if ( strType.equals( "y" ) ) {
            return new Double( startDate.get( Calendar.DAY_OF_YEAR ) );
          } else if ( strType.equals( "m" ) ) {
            return new Double( startDate.get( Calendar.DAY_OF_MONTH ) );
          } else if ( strType.equals( "w" ) ) {
            return new Double( startDate.get( Calendar.DAY_OF_WEEK ) );
          } else if ( strType.equals( "wm" ) ) {
            return new Double( startDate.get( Calendar.DAY_OF_WEEK_IN_MONTH ) );
          }
          return new Double( startDate.get( Calendar.DAY_OF_YEAR ) );
        }
      } catch ( Exception e ) {
        return null;
        // throw Context.reportRuntimeError(e.toString());
      }
    } else {
      throw Context.reportRuntimeError( "The function call getDayNumber requires 2 arguments." );
    }
  }

  public static Object isWorkingDay( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        } else {
          java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
          Calendar startDate = Calendar.getInstance();
          startDate.setTime( dIn );
          if ( startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SATURDAY
            && startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SUNDAY ) {
            return Boolean.TRUE;

View on GitHub (pinned to f3058517a1)