Reputation: 39
I want to calculate the remaining duration using an SQL query or using PHP. I have a table that has fields
- date_submit
(example 2019-12-01 09:40:22 ) and
- duration
( example 30 days )
For example today is 2019-12-02 so the remaining duration is 29, how can I calculate this in SQL or PHP?
Upvotes: 0
Views: 141
Reputation: 147166
In your SQL query, you can use TIMESTAMPDIFF
to compute the remaining duration:
SELECT TIMESTAMPDIFF(DAY, CURDATE(), DATE(date_submit) + INTERVAL duration DAY) AS remaining
Upvotes: 1