Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql, days from date interval

Tags:

postgresql

I need to find all rows from database table, for which the difference between columns date_start and date_end is exactly 3 days. 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:

"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). Could anyone explain me, where is my mistake?

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?

like image 356
Vitali K Avatar asked Jul 06 '26 22:07

Vitali K


1 Answers

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). But I found some around way. Just selected general information from the table, and all required checkes I have done in java classes.

like image 196
Vitali K Avatar answered Jul 12 '26 16:07

Vitali K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!