select *
from sample_table scr
where extract('epoch' from systimestamp - scr.created_date)/60 > :defaultTimeOut
这是一个postgres查询。尝试将此查询转换为oracle。
如何在oracle中转换纪元?
TIA。
select *
from sample_table scr
where extract('epoch' from systimestamp - scr.created_date)/60 > :defaultTimeOut
这是一个postgres查询。尝试将此查询转换为oracle。
如何在oracle中转换纪元?
TIA。
您实际上是在尝试将间隔(即两个日期之间的差)转换为秒数。假设created_date
的数据类型为date
,一种方法是:
select *
from sample_table
where (sysdate - created_date) * 24 * 60 * 60 > :defaultTimeOut
理论值:在Oracle中,将两个日期相减将返回一个十进制数字,该数字表示天数之差。您可以将其乘以24(每天的小时数),60(每小时的分钟数)和60(每分钟的秒数),以将其转换为秒数,然后将其与目标值进行比较。
如果created_date
是timestamp
数据类型,则可以先将其强制转换为date
:
select *
from sample_table
where (sysdate - cast(created_date as date)) * 24 * 60 * 60 > :defaultTimeOut