Postgresql 将字段日期的返回数据获取为当前日期

Postgresql 将字段日期的返回数据获取为当前日期,postgresql,Postgresql,我想返回今天输入的所有条目,无论何时使用它插入 INSERT INTO hangfire.job(stateid, statename, invocationdata, arguments, createdat, expireat, updatecount) VALUES (44, 'Schedule', 'Test Invocation data', 'Test arguments', now()::timestamp, null, 0); 并使用它检索数据,但它不返回任何内容,只返回字段

我想返回今天输入的所有条目,无论何时使用它插入

INSERT INTO hangfire.job(stateid, statename, invocationdata, arguments, createdat, expireat, updatecount)
VALUES (44, 'Schedule', 'Test Invocation data', 'Test arguments', now()::timestamp, null, 0);
并使用它检索数据,但它不返回任何内容,只返回字段

SELECT * From hangfire.job WHERE createdat = now()::timestamp;

时间戳包含一个时间(如名称所示),如果要忽略该时间,请使用
date

SELECT * 
From hangfire.job 
WHERE createdat::date = current_date;
如果您在createdat上有一个索引,则上面的索引将不会使用该索引。如果出于性能原因需要,请使用范围条件:

SELECT * 
From hangfire.job 
WHERE createdat >= current_date
  AND createdat < current_date + 1;
选择*
来自hangfire.job
其中createdat>=当前日期
和createdat
不相关,但是:
now()::timestamp
可以简化为
localtimestamp