Find difference between timestamps in seconds in P

2019-05-23 02:56发布

问题:

I need to find the difference between two timestamps in seconds using JOOQ. I have taken a look at some answers on StackOverflow using raw SQL, however i didn´t find a way to implement it using JOOQ.

Here are some solutions that i found that are using raw SQL:

  • Find difference between timestamps in seconds in PostgreSQL
  • MySQL: how to get the difference between two timestamps in seconds

回答1:

Use DSL.timestampDiff(timestamp1, timestamp2). It will return the difference in terms of an INTERVAL DAY TO SECOND type: org.jooq.types.DayToSecond