{"record":{"id":"7d4eee3ab9567e55","repo":"pentaho/pentaho-kettle","slug":"to-date-couldn-t-convert-string-to-date","errorCode":null,"errorMessage":"TO_DATE Couldn't convert String to Date","messagePattern":"TO_DATE Couldn't convert String to Date","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":3168,"sourceCode":"\n      SimpleDateFormat df = new SimpleDateFormat();\n\n      DateFormatSymbols dfs = new DateFormatSymbols();\n      if ( arg1 != null ) {\n        dfs.setLocalPatternChars( arg1 );\n      }\n      if ( arg0 != null ) {\n        df.applyPattern( arg0 );\n      }\n\n      try {\n        value.setDate( df.parse( getString() ) );\n        setType( VALUE_TYPE_DATE );\n        setLength( -1, -1 );\n      } catch ( Exception e ) {\n        setType( VALUE_TYPE_DATE );\n        setNull();\n        throw new KettleValueException( \"TO_DATE Couldn't convert String to Date\" + e.toString() );\n      }\n    }\n    return this;\n  }\n\n  // implement the TO_NUMBER function, arguments in args[]\n  public Value str2num() throws KettleValueException {\n    return str2num( null, null, null, null );\n  }\n\n  public Value str2num( String pattern ) throws KettleValueException {\n    return str2num( pattern, null, null, null );\n  }\n\n  public Value str2num( String pattern, String decimal ) throws KettleValueException {\n    return str2num( pattern, decimal, null, null );\n  }\n","sourceCodeStart":3150,"sourceCodeEnd":3186,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L3150-L3186","documentation":"Thrown when the legacy Value str2dat/TO_DATE function's SimpleDateFormat.parse() of getString() fails. The value is reset to a null Date before rethrowing; the cause (usually unparseable text or a mismatched pattern in arg0) is appended to the message.","triggerScenarios":"Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the TO_DATE format pattern (arg0) match the actual layout of the input string","Clean or pre-trim the source string so it conforms to the expected date format","Handle null/blank input before calling TO_DATE"],"exampleFix":null,"handlingStrategy":"try-catch","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"}