{"record":{"id":"e2061915f06ef0df","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getdaynumber-requires-2-arguments","errorCode":null,"errorMessage":"The function call getDayNumber requires 2 arguments.","messagePattern":"The function call getDayNumber requires 2 arguments\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":447,"sourceCode":"          Calendar startDate = Calendar.getInstance();\n          startDate.setTime( dIn );\n          if ( strType.equals( \"y\" ) ) {\n            return new Double( startDate.get( Calendar.DAY_OF_YEAR ) );\n          } else if ( strType.equals( \"m\" ) ) {\n            return new Double( startDate.get( Calendar.DAY_OF_MONTH ) );\n          } else if ( strType.equals( \"w\" ) ) {\n            return new Double( startDate.get( Calendar.DAY_OF_WEEK ) );\n          } else if ( strType.equals( \"wm\" ) ) {\n            return new Double( startDate.get( Calendar.DAY_OF_WEEK_IN_MONTH ) );\n          }\n          return new Double( startDate.get( Calendar.DAY_OF_YEAR ) );\n        }\n      } catch ( Exception e ) {\n        return null;\n        // throw new RuntimeException(e.toString());\n      }\n    } else {\n      throw new RuntimeException( \"The function call getDayNumber requires 2 arguments.\" );\n    }\n  }\n\n  public static Object isWorkingDay( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return undefinedValue;\n        } else {\n          java.util.Date dIn = (java.util.Date) ArgList[0];\n          Calendar startDate = Calendar.getInstance();\n          startDate.setTime( dIn );\n          if ( startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SATURDAY\n            && startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SUNDAY ) {\n            return Boolean.TRUE;","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L429-L465","documentation":"getDayNumber(datePart, date) is a Script step JavaScript helper that returns the numeric day value of a date. It requires exactly two arguments and throws this RuntimeException when the argument count differs, since it cannot guess which date or which date part the caller intended.","triggerScenarios":"Calling getDayNumber() in script with fewer or more than two arguments, e.g. getDayNumber(date) or getDayNumber('d', date, extra).","commonSituations":"Migrating scripts between Kettle/Pentaho versions where the signature changed; forgetting the date-part selector argument; extra args added by copy-paste.","solutions":["Call with exactly two arguments: getDayNumber('d', myDate) — date part selector first, then the date.","Verify the date argument is a valid Date object, not a string.","Consult the Script step function reference for the exact signature."],"exampleFix":"// before\nvar d = getDayNumber(myDate);\n// after\nvar d = getDayNumber('d', myDate);","handlingStrategy":"validation","validationCode":"if (myDate instanceof Date) { var d = getDayNumber('d', myDate); }","typeGuard":"function isDate(v) { return v instanceof Date && !isNaN(v.getTime()); }","tryCatchPattern":"try { var d = getDayNumber('d', myDate); } catch (e) { if (/getDayNumber requires 2 arguments/.test(String(e))) { d = null; } else { throw e; } }","preventionTips":["Pass the date-part string first, then the Date.","Verify argument order against the function reference before reuse.","Convert string fields to Date before using date helpers."],"tags":["javascript","script-step","argument-count"],"backgroundTag":"missing-required-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}