As far as I can see, {fn timestampdiff(SQL_TSI_MINUTE, a, b)} is
translated as extract(minute from (b-a)), so it is not right.
So something like extract(epoch from (b-a))/60 should be used.
Here's a test case:
select x.v
, extract(minute from x.v) extract_minute -- returns 30
, extract(hour from x.v) extract_hour -- returns 1
, extract(epoch from x.v) extract_epoch -- returns 5400
, (extract(epoch from x.v)/60)::bigint extract_epoch_div_60 -- returns 90
from (select interval '1:30' day to second as v) as x
Vladimir