JavaSa
JavaSa

Reputation: 6242

How can I find entries that has a date(day and month only which are interval of the next 3 days)

Have a field of type Date.
I know there is someway of getting interval of last month like, something like
NOW() - INTERVAL 1 MONTH.

What I need is:

If today is 7.4.15 then I need to select all the entries in a table which has the date field set to 8.4.XX 9.4.XX 10.4.XX - year doesn't matter!

Edit: I need also to know how to know use some day interval for searching the next 3 days.

Upvotes: 0

Views: 25

Answers (1)

Dobromir Velev
Dobromir Velev

Reputation: 520

I would use something like this though it is not very efficient

select * from table where 
  date_format(datefield,'%m%d') between 
  date_format(Now() + interval 1 day,'%m%d') and date_format(Now() + interval 3 day,'%m%d');

You can probably use %j (day of year 1-366) but I am not sure how it will work for leap years.

Upvotes: 1

Related Questions