fantic Posted November 20, 2008 Share Posted November 20, 2008 what is the query for 3 month interval(only month should be displayed) in mysql. I want to show like janauary to march or november to january of next year. plz help me. Link to comment https://forums.phpfreaks.com/topic/133480-month-interval-on-mysql/ Share on other sites More sharing options...
fenway Posted November 20, 2008 Share Posted November 20, 2008 You mean like + INTERVAL 3 MONTH? Link to comment https://forums.phpfreaks.com/topic/133480-month-interval-on-mysql/#findComment-694409 Share on other sites More sharing options...
fantic Posted November 21, 2008 Author Share Posted November 21, 2008 3 months period for ex: if this month is November then October,November and December or if This month is December than November, December and January Link to comment https://forums.phpfreaks.com/topic/133480-month-interval-on-mysql/#findComment-695111 Share on other sites More sharing options...
corbin Posted November 21, 2008 Share Posted November 21, 2008 SELECT blah FROM table WHERE SomeColumn BETWEEN something AND SomethingElse; Depending on the format of your column, you will need to use the corresponding values there. Example: SELECT * FROM events WHERE event_date (BETWEEN DATE_ADD(NOW(), INTERVAL + 3 MONTHS) AND DATE_ADD(NOW(), INTERVAL + 4 MONTHS)); Link to comment https://forums.phpfreaks.com/topic/133480-month-interval-on-mysql/#findComment-695128 Share on other sites More sharing options...
fenway Posted November 21, 2008 Share Posted November 21, 2008 or BETWEEN event_date - INTERVAL 1 MONTH AND event_date + INTERVAL 1 MONTH But of course you'll need to start for the beginning of the month, so you might want to use extract the YEARMONTH. Link to comment https://forums.phpfreaks.com/topic/133480-month-interval-on-mysql/#findComment-695736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.