{"record":{"id":"b9759df04fb2a565","repo":"pentaho/pentaho-kettle","slug":"function-num2dat-only-works-on-a-number","errorCode":null,"errorMessage":"Function NUM2DAT only works on a number","messagePattern":"Function NUM2DAT only works on a number","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":3135,"sourceCode":"        }\n      } else {\n        throw new KettleValueException( \"Function DAT2STR only works on a date\" );\n      }\n    }\n\n    return this;\n  }\n\n  // implement the TO_DATE function, arguments in args[]\n  public Value num2dat() throws KettleValueException {\n    if ( isNull() ) {\n      setType( VALUE_TYPE_DATE );\n    } else {\n      if ( isNumeric() ) {\n        setValue( new Date( getInteger() ) );\n        setLength( -1, -1 );\n      } else {\n        throw new KettleValueException( \"Function NUM2DAT only works on a number\" );\n      }\n    }\n    return this;\n  }\n\n  public Value str2dat( String arg0 ) throws KettleValueException {\n    return str2dat( arg0, null );\n  }\n\n  public Value str2dat( String arg0, String arg1 ) throws KettleValueException {\n    if ( isNull() ) {\n      setType( VALUE_TYPE_DATE );\n    } else {\n      // System.out.println(\"Convert string [\"+string+\"] to date using pattern '\"+arg0+\"'\");\n\n      SimpleDateFormat df = new SimpleDateFormat();\n\n      DateFormatSymbols dfs = new DateFormatSymbols();","sourceCodeStart":3117,"sourceCodeEnd":3153,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L3117-L3153","documentation":"Guard in the legacy Value num2dat() function: the value is non-null and not numeric (isNumeric() false), so it cannot be interpreted as an epoch millisecond value for Date construction. The input at fault is the current Value of a non-numeric type.","triggerScenarios":"Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the field passed to NUM2DAT is an Integer/Number/BigNumber holding epoch milliseconds","Convert or parse the value to a numeric type before calling NUM2DAT"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}