pentaho/pentaho-kettle · error · KettleValueException
Function DAT2NUM works only on dates
Error message
Function DAT2NUM works only on dates
What it means
Guard in the legacy Value dat2num() function: the value's type is not VALUE_TYPE_DATE, so the date-to-number (epoch) conversion is refused. The input at fault is the current Value with a non-date type.
Solutions
- Ensure the field passed to DAT2NUM is a Date
- Convert the value to a Date first (e.g. str2dat or num2dat) before calling DAT2NUM
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3262 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/54d1c78727f578b6.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3262
}
return this;
}
public Value dat2num() throws KettleValueException {
if ( isNull() ) {
setType( VALUE_TYPE_INTEGER );
return this;
}
if ( getType() == VALUE_TYPE_DATE ) {
if ( getString() == null ) {
setNull();
setValue( 0L );
} else {
setValue( getInteger() );
}
} else {
throw new KettleValueException( "Function DAT2NUM works only on dates" );
}
return this;
}
/**
* Performs a right and left trim of spaces in the string. If the value is not a string a conversion to String is
* performed first.
*
* @return The trimmed string value.
*/
public Value trim() {
if ( isNull() ) {
setType( VALUE_TYPE_STRING );
return this;
}
String str = Const.trim( getString() );
setValue( str );View on GitHub (pinned to f3058517a1)