如何在postgres中选择日期范围? [英] How do you select a date range in postgres?

查看:104
本文介绍了如何在postgres中选择日期范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在postgres数据库中有一个时间戳记字段。我想选择上个月发生的所有日期。所以有一些像select *从表的时间戳>(当前时间戳 - 1个月)。

I have a timestamp field in a postgres database. I would like to select all dates that have happened within the last month. So something like select * from table where timestamp > (current timestamp - 1 month).

推荐答案

select * from table where timestamp > now() - interval '1 month'

这篇关于如何在postgres中选择日期范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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