I have a tbl_subscriptions table and columns like this "id, user_name, join_date (date)", I want to select users up to 7 days each month based on join_date so that I can send them notifications to continue subscribing next month. I have entries like this
1, user1, 2014-05-02
2, user2, 2014-05-04
3, user3, 2014-06-12
4, user4, 2014-06-20
4, user5, 2014-07-24
If today 2014-07-28, then I want to get records 1 and 2. I tried the following query
SELECT *,
datediff( date_format(date, '2014-07-%d'), now() ) as daysLeft
FROM tbl_subscriptions
HAVING daysLeft >= 0
AND daysLeft < 7
The problem with the above sql is that it selects the record of only the current month, PLZ offers the best query.
source
share