Reputation: 2032
I have a table called "Task" which has, among others, two columns:
I want to add the Wait_in_seconds value to the date in the query and compare it to the current date.
The query below doesn't have the right syntax, but it indicates what I want:
SELECT t
FROM Task t
WHERE (Date_due + Wait_in_seconds) < CURRENT_TIMESTAMP
Edit: KIMI explains that this is not possible with JPQL.
Edit 2: This native MySQL query does the trick:
SELECT *, DATE_ADD(task.date_due, INTERVAL task.wait_seconds SECOND) AS dueDate
FROM task
HAVING dueDate < NOW()
ORDER BY dueDate ASC
Upvotes: 3
Views: 7234