Reputation: 259
I have this query:
SELECT DATE_FORMAT( expiry_date
, '%d.%m.%Y' ) FROM my_subscriptions
WHERE user_id
= '[user_id]'
which extract expiry date of users subscription plan of my site. Now I would like use another query who count and extract remaining days before reach expiration date. I'm not a sql guru and have poor knowledge about. Any suggestions ?
Upvotes: 0
Views: 1462
Reputation: 21657
You would do
SELECT DATEDIFF(expiry_date,NOW()) AS days
FROM my_subscriptions WHERE user_id = '[user_id]';
Upvotes: 4
Reputation: 8457
SELECT DATEDIFF(expiry_date, CURDATE()) AS days_until_expire FROM my_subscriptions WHERE user_id = '[user_id]'
Upvotes: 2