小编man*_*lla的帖子

PostgreSQL:如何从今天的日期获取过去 2 年的数据

我正在使用 PostgreSQL,需要知道如何从今天开始获取过去 2 年的数据,即 current_date。我的查询正确吗?

select count(*) from table_name where
creation_date >= date_trunc('year', now()) - interval '2' year and
creation_date < date_trunc('year', now());
Run Code Online (Sandbox Code Playgroud)

postgresql

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

postgresql ×1