Hello.

1. You can't legally use expressions as the first parameter of this 
function, H2 officially supports only datetime fields:
https://h2database.com/html/functions.html#datediff

The valid syntax is TIMESTAMPDIFF(HOUR, arg1, arg2).

H2 accepts character string literals too for some limited compatibility 
with old unsupported versions, but intentionally does not allow other 
expressions any more. The reason is very simple: H2 need to know what to 
return from this function during its compilation, but type of result 
depends on used datetime field.

2. It is better to use DATEDIFF (the primary name of this function) instead 
of its second name TIMESTAMPDIFF in generated code.

3. It is rarely appropriate to use this function, it actually returns the 
number of crossed unit boundaries and not the real difference between two 
timestamps. Recent releases of H2 supports standard datetime and interval 
arithmetic, for example, you can use WHERE timestamp1 > timestamp2 + 
INTERVAL '9999' DAY or something like it. You can pass intervals as 
parameters, but in some cases you may need to add explicit casts around 
them (something like CAST(? AS INTERVAL(18) DAY) or whatever you need).

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/2562ef11-4490-4e4e-bce2-92951bb1a705o%40googlegroups.com.

Reply via email to