小编pau*_*ulf的帖子

postgres '1 年' 等于 '360 天'?

我想知道是否有其他人遇到过这种情况或知道有关它的信息。

今天是 2014 年 11 月 3 日,如果我检查 2013 年 11 月 5 日是否在去年内,我会得到不同的答案,具体取决于我检查的方式:1 年与 365 天

select now() - '20131105' as diff, 
case when now() - '20131105' <= '1 year' then 'within year' else 'not within year' end as yr_check,
case when now() - '20131105' <= '365 days' then 'within 365 days' else 'not within 365 days' end as day_check

2014-11-03 16:27:38.39669-06;  363 days 16:27:38.39669;  not within year;  within 365 days
Run Code Online (Sandbox Code Playgroud)

好像查询到11月9日的时候,没问题

select now() as right_now, now() - '20131109' …
Run Code Online (Sandbox Code Playgroud)

postgresql datediff

2
推荐指数
1
解决办法
1877
查看次数

标签 统计

datediff ×1

postgresql ×1