开发者

Mysql Query to show exact 7 days expiring clients

I开发者_Go百科 am having a bit of difficulty in getting the right value.

What I want to query is, the users who expire in 7 days, for example on 4th Oct 2011, the query should display the result of that particular day only. Right now I am querying as below:

select * from users where exp_date between now() and adddate(now(), INTERVAL 7 DAY).

this query keep display till next 7 days.

But i want to show only for on 7th day expiring clients as I move on to tomorrow's date then the today's displayed query should not display on tomorrow's display rather it show the expiring client on 5th Oct 2011 and so on.

How do I achieve this? please help


TRY This:

SELECT * FROM users WHERE exp_date = DATE_ADD(CURDATE(), INTERVAL 7 DAY)

Make sure your exp_date field is DATE type


Try this
WHERE exp_date = CURDATE()+7

You may add days or subtract days as you move on calender like this:
WHERE exp_date = CURDATE()+7+$daysoffset
where $daysoffset is 0 for Today, 1 for Tomorrow.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜