The field delay_endings_days represents the number of days since the deadline.
This field was using the write_date instead of now to compute it and was using the absolute value (so project in advance would also get overdue days
planned_hours as hours_planned,
(extract('epoch' from (t.write_date-t.create_date)))/(3600*24) as closing_days,
(extract('epoch' from (t.date_start-t.create_date)))/(3600*24) as opening_days,
- abs((extract('epoch' from (t.date_deadline-t.write_date)))/(3600*24)) as delay_endings_days
+ (extract('epoch' from (t.date_deadline-now())))/(3600*24) as delay_endings_days
FROM project_task t
WHERE t.active = 'true'
GROUP BY