{"record":{"id":"5485a4edf0e2bdfe","repo":"pentaho/pentaho-kettle","slug":"function-trunc-only-works-with-numbers-and-dates","errorCode":null,"errorMessage":"Function TRUNC only works with numbers and dates","messagePattern":"Function TRUNC only works with numbers and dates","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":3523,"sourceCode":"          cal.set( Calendar.DAY_OF_MONTH, 1 );\n          // HOURS\n        case 3:\n          cal.set( Calendar.HOUR_OF_DAY, 0 );\n          // MINUTES\n        case 2:\n          cal.set( Calendar.MINUTE, 0 );\n          // SECONDS\n        case 1:\n          cal.set( Calendar.SECOND, 0 );\n          // MILI-SECONDS\n        case 0:\n          cal.set( Calendar.MILLISECOND, 0 );\n          break;\n        default:\n          throw new KettleValueException( \"Argument of TRUNC of date has to be between 0 and 5\" );\n      }\n    } else {\n      throw new KettleValueException( \"Function TRUNC only works with numbers and dates\" );\n    }\n\n    return this;\n  }\n\n  /**\n   * Change a string into its hexadecimal representation. E.g. if Value contains string \"a\" afterwards it would contain\n   * value \"61\".\n   *\n   * Note that transformations happen in groups of 2 hex characters, so the value of a characters is always in the range\n   * 0-255.\n   *\n   * @return Value itself\n   * @throws KettleValueException\n   */\n  public Value byteToHexEncode() {\n    final char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };\n","sourceCodeStart":3505,"sourceCodeEnd":3541,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L3505-L3541","documentation":"Type dispatch guard in the argumented legacy Value trunc(level) overload: the value is not a Number or Date, so no truncation case matches and the sentinel error is thrown. The input at fault is the current Value of an unsupported type.","triggerScenarios":"Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3523 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the field passed to TRUNC is a Number or Date","Convert the value to a supported type before truncating"],"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"}