I would say that the easiest solution is to create your own custom HSQLDB dialect that extends the existing HSQLDB dialogs. Then, in the constructor, register a function for processing the datiff (date1, date2), which will be converted to dated (interval, date1, date2), provided that the interval is a static value. Something like that:
registerFunction( "datediff", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datediff(interval, ?1, ?2)" ) );
source share