T
T
tigra2015-09-18 17:12:45
MySQL
tigra, 2015-09-18 17:12:45

How to display the time interval that I need?

I need to display records with an interval of half a year.
I write:

SELECT * FROM `calendar` WHERE MONTH(`date`) BETWEEN MONTH(NOW()) AND (MONTH(NOW()) + 4)

it displays all the data for 5 months, but grabs another record for a month from another year.
Who will tell, otherwise he broke his whole headd008ad6a2e9042dfafbe3c7218f7e273.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2015-09-18
@tigroid3

something like this:

SELECT * FROM `calendar` WHERE `date` BETWEEN NOW() AND DATE_ADD(NOW(),INTERVAL 6 MONTH);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question