Mr Gulerod
Mr Gulerod

Reputation: 3

MySQL Where date between 9 and 10 days

I'm trying to make a query that will select all my users who's donor status is ending within 10 days. As i only want to send the message once I want to select all the users who has their donor status ending between 10 and 9 days ahead.

The Donor end date is in this format: 0000-00-00 00:00:00

This is the query I'm currently working around with:

SELECT UserID FROM users_info WHERE donorEnd BETWEEN (NOW() + INTERVAL 10 DAY) AND (NOW() + INTERVAL 9 DAY)

Upvotes: 0

Views: 393

Answers (1)

xkothe
xkothe

Reputation: 674

I think you problem is that you are adding a time not a date: NOW() + INTERVAL 9 DAY = 2015-02-27 19:19 not 2015-02-27 00:00 Try use ADDDATE with CURDATE():

SELECT UserID FROM users_info WHERE donorEnd BETWEEN DATE_ADD(CURDATE(), INTERVAL 9 DAY) AND DATE_ADD(CURDATE(), INTERVAL 9 DAY)

Upvotes: 1

Related Questions