使用JOOQ在PostgreSQL中找到时间戳之间的差异(以秒为单位) [英] Find difference between timestamps in seconds in PostgreSQL using JOOQ

查看:239
本文介绍了使用JOOQ在PostgreSQL中找到时间戳之间的差异(以秒为单位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用JOOQ以秒为单位查找两个时间戳之间的差异
我已经使用原始SQL查看了StackOverflow上的一些答案,但是我没有找到使用JOOQ来实现它的方法。

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.

这里有一些我发现使用原始SQL的解决方案:

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

推荐答案

使用 DSL.timestampDiff(timestamp1,timestamp2) 。它将以秒间隔时间类型的形式返回差额: org.jooq.types.DayToSecond

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

这篇关于使用JOOQ在PostgreSQL中找到时间戳之间的差异(以秒为单位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆