Only month part can be collected from MySQL date and time field by using month function. This will collect the month in number format ( 1 to 12 )
Please note that it will not take care of year part. So if you are taking the difference in month for July 2004 and August 2005 then you will get a difference of one.
Syntax
This will fail if the dates are more than a couple of years apart.
smo
15-09-2009
You can see from the above table that this only gives the numeric difference of the month values without considering the years. So it is not expected to give you correct difference in months
Mahma
28-08-2014
Hi , I am trying to get Data from a SQL server between 2 dates,but if the month of from_date is higher than to_date it doesn't return me any records.
Please help me with the same.