简体   繁体   English

Postgresql,从日期间隔开始的几天

[英]Postgresql, days from date interval

I need to find all rows from database table, for which the difference between columns date_start and date_end is exactly 3 days. 我需要从数据库表中查找所有行,其中date_startdate_end列之间的差异date_end是3天。 I looked through postgresql documentation like http://www.postgresql.org/docs/9.1/static/datatype-datetime.html , and have already created several queries, for example: 我浏览了像http://www.postgresql.org/docs/9.1/static/datatype-datetime.html这样的postgresql文档,并且已经创建了几个查询,例如:

"SELECT e FROM Events e WHERE date_part('day',(e.date_end - e.date_start)) = 3"

but unfortunately my editor give an error "The query contains a malformed ending" and "The identification variable 'date_part' is not defined in the FROM clause" (Eclipse). 但遗憾的是我的编辑器发出错误"The query contains a malformed ending"错误"The query contains a malformed ending""The identification variable 'date_part' is not defined in the FROM clause" (Eclipse)。 Could anyone explain me, where is my mistake? 任何人都可以解释一下,我的错误在哪里?

EDIT1: EDIT1:

Maybe eclipse does not know all postgresql functions and I have to import some library or add something into query to make date_part function visible for the environment? 也许eclipse不知道所有postgresql函数,我必须导入一些库或在查询中添加一些东西,使date_part函数对环境可见?

Unfortunately I did not find solution using postgresql queries, just cause my eclipse editor always give me an errors referenced to the postgresql functions (do not know some of them). 不幸的是我没有找到使用postgresql查询的解决方案,只是因为我的eclipse编辑器总是给我一个引用postgresql函数的错误(不知道其中的一些)。 But I found some around way. 但我发现了一些方法。 Just selected general information from the table, and all required checkes I have done in java classes. 刚刚从表中选择了一般信息,以及我在java类中完成的所有必需检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM