{"record":{"id":"b5407d484f6fa9be","repo":"pentaho/pentaho-kettle","slug":"i-don-t-know-how-to-convert-date-values-to-booleans","errorCode":null,"errorMessage":" : I don't know how to convert date values to booleans.","messagePattern":" : I don't know how to convert date values to booleans\\.","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":2289,"sourceCode":"            return convertNumberToBoolean( (Double) convertBinaryStringToNativeType( (byte[]) object ) );\n          case STORAGE_TYPE_INDEXED:\n            return convertNumberToBoolean( (Double) index[( (Integer) object ).intValue()] );\n          default:\n            throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n        }\n      case TYPE_BIGNUMBER:\n        switch ( storageType ) {\n          case STORAGE_TYPE_NORMAL:\n            return convertBigNumberToBoolean( (BigDecimal) object );\n          case STORAGE_TYPE_BINARY_STRING:\n            return convertBigNumberToBoolean( (BigDecimal) convertBinaryStringToNativeType( (byte[]) object ) );\n          case STORAGE_TYPE_INDEXED:\n            return convertBigNumberToBoolean( (BigDecimal) index[( (Integer) object ).intValue()] );\n          default:\n            throw new KettleValueException( toString() + \" : Unknown storage type \" + storageType + \" specified.\" );\n        }\n      case TYPE_DATE:\n        throw new KettleValueException( toString() + \" : I don't know how to convert date values to booleans.\" );\n      case TYPE_BINARY:\n        throw new KettleValueException( toString() + \" : I don't know how to convert binary values to booleans.\" );\n      case TYPE_SERIALIZABLE:\n        throw new KettleValueException( toString() + \" : I don't know how to convert serializable values to booleans.\" );\n      default:\n        throw new KettleValueException( toString() + \" : Unknown type \" + type + \" specified.\" );\n    }\n  }\n\n  @Override\n  public Date getDate( Object object ) throws KettleValueException {\n    if ( isNull( object ) ) {\n      return null;\n    }\n    switch ( type ) {\n      case TYPE_DATE:\n        switch ( storageType ) {\n          case STORAGE_TYPE_NORMAL:","sourceCodeStart":2271,"sourceCodeEnd":2307,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L2271-L2307","documentation":"ValueMetaBase.getBoolean() intentionally does not support TYPE_DATE: there is no defined Date→Boolean conversion, so the method throws KettleValueException 'I don't know how to convert date values to booleans.' This is a deliberate unsupported-conversion error, not a data corruption issue — the field's declared type is Date while the consumer expects a Boolean.","triggerScenarios":"getBoolean(object) (or row.getBoolean / RowMeta.getBoolean on a Date-typed column) on a ValueMeta with type TYPE_DATE.","commonSituations":"Downstream steps or JavaScript/User Defined Java expressions assuming every field can be coerced to boolean; SQL/table input where a DATE column maps to TYPE_DATE but the transformation logic branches on it; schema drift where a column changed from boolean to date upstream.","solutions":["Convert the date explicitly to the comparison you need (e.g. valueMeta.getBoolean(convertDateToBoolean) is unavailable — instead compare dates: date != null / date.before(...))","Fix the field metadata at the source so the column is TYPE_BOOLEAN (or string 'Y'/'N')","Use a 'Value Mapper' or 'If field value is null'/Calculator step to derive a boolean from the date before getBoolean()"],"exampleFix":"// before\nValueMetaInterface meta = new ValueMetaBase(\"updated\", ValueMetaInterface.TYPE_DATE);\nBoolean b = meta.getBoolean(rowData); // throws\n// after\nValueMetaInterface meta = new ValueMetaBase(\"updated\", ValueMetaInterface.TYPE_DATE);\nDate d = meta.getDate(rowData);\nBoolean b = d != null; // explicit business rule instead of implicit coercion","handlingStrategy":"type-guard","validationCode":"if (meta.getType() == ValueMetaInterface.TYPE_DATE) {\n  // Dates cannot be coerced to booleans in Kettle; apply an explicit rule\n  Date d = meta.getDate(value);\n  Boolean b = (d != null) && d.before(cutoffDate);\n} else {\n  Boolean b = meta.getBoolean(value);\n}","typeGuard":"boolean isBooleanReadable(ValueMetaInterface m) {\n  int t = m.getType();\n  return t == ValueMetaInterface.TYPE_BOOLEAN || t == ValueMetaInterface.TYPE_STRING\n      || t == ValueMetaInterface.TYPE_INTEGER || t == ValueMetaInterface.TYPE_NUMBER\n      || t == ValueMetaInterface.TYPE_BIGNUMBER;\n}","tryCatchPattern":"try {\n  Boolean b = meta.getBoolean(value);\n} catch (KettleValueException e) {\n  if (e.getMessage().contains(\"date values to booleans\")) {\n    Date d = meta.getDate(value); // convert via explicit business rule\n    Boolean b = d != null;\n  } else { throw e; }\n}","preventionTips":["Use meta.getType()/isDate() before calling getBoolean()","Derive booleans from dates with explicit comparisons (null check, before/after)","Lock upstream schemas so boolean columns don't drift to DATE types"],"tags":["kettle","pdi","type-conversion","unsupported-conversion"],"backgroundTag":"unsupported-operation","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"}