PostgreSql中的变量(pgAdmnin查询)

时间:2014-09-10 12:42:39

标签: postgresql variables

我有一个查询

delete from qdocs where path < './qbin/arch/2014-08-01' + and path > './qbin/arch'

需要制作像

这样的变量
delete from qdocs where path < './qbin/arch/current_date - 31 day' + and path > './qbin/arch'

1 个答案:

答案 0 :(得分:0)

您可以使用下面的date/time functions

delete from qdocs where path < './qbin/arch/' || current_date - 31 and path > './qbin/arch'

有更多可能的方法来修改日期:

select current_date - integer '31';
select (current_date - interval '31 days')::date;
select (current_date - interval '1 month')::date;