I have a requirement to calculate the number of days from 3 different dates. I need to run the logic to get an integer value from below pseudo logic.
(future_date_1 - future_date_2) - Today()
How to achieve this in PostgreSQL?
In order to achieve the date difference in days,
SELECT DATE_PART('day', '2011-12-31 01:00:00'::timestamp - '2011-12-29 23:00:00'::timestamp);
OR
this also works pretty well
select '2015-01-12'::date - '2015-01-01'::date;
Now, you only need to use this logic and satisfy your requirement.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.