将纪元与当前日期的纪元格式进行比较

时间:2013-07-26 09:01:38

标签: postgresql

如何将列值与当前日期的纪元格式进行比较?

尝试以下查询:

select f_id from (select (extract(epoch from now()))) as epochNow, data_history 
where   (extract(epoch from f_lastmodified) + f_retention_period) < epochNow 

ERROR :
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

********** Error **********

ERROR: operator does not exist: double precision < record
SQL state: 42883

任何指针?

1 个答案:

答案 0 :(得分:0)

尝试类似:

select f_id 
from data_history 
where   (extract(epoch from f_lastmodified) + f_retention_period) < extract(epoch from now())

当你写道:

from (select (extract(epoch from now()))) as epochNow

你创建了一个子查询thar,返回一行一列。并且您将此子查询命名为epochNow