Reputation: 259
I have actually this query:
SELECT DATE_FORMAT(DATE_ADD(`expiry_date`,INTERVAL 7 DAY), '%d.%m.%Y' )
FROM `my_table`
WHERE `user_id` = '[user_id]';
This was planned for add 7 days to expiry_date field stored in user account. Now I need to fork this query and instead to get expiry_date I need to get current date (today date). Then instead to add 7 days I need to add the number of day present in the field allowed_days.
I make some test, but I'm a sql newbie and I afraid to broke my database. If somebody could help...Thank.
Upvotes: 0
Views: 453
Reputation: 1269443
What you want to do is just a slight variation on your query. Because you are a newbie . . .
SELECT DATE_FORMAT(DATE_ADD(now(), INTERVAL allowed_days DAY), '%d.%m.%Y' )
FROM `my_table`
WHERE `user_id` = '[user_id]';
Upvotes: 1