MAX Date range from multiple records
I have a table like below.
Customer Publication Start Date End Date
1 S0048 DLD 01-JAN-2013 15-NOV-2013
2 S0048 DLD 03-MAR-2013 31-DEC-2013
3 S0048 SLD 01-FEB-2013 31-DEC-2013
4 S0048 SLD 01-FEB-2013 30-NOV-2013
5 S0145 DLD 01-JAN-2013 01-MAR-2013
6 S0145 DLD 02-FEB-2013 28-NOV-2013
I need to get the result by giving end date range.
Ex: If input : end date 01-NOV-2013 to 30-NOV-2013
(Searching who are expiring with in NOV month)
Results should be
S0145 DLD 02-FEB-2013 28-NOV-2013
Please note that 1st and 4th records should not be there as they have renew their publication subscription period.
How can I get these result. please help.
Dear All, I can get the data for a given date range. But it returns 1 , 4 ,6 . I need only record 6 to be return. Cause i need the latest date range for a specified customer for a publication.(Highest date range of each customer each publication). As to my input (searching the November month end dates). 1 is not necessary as that customer had extended the 'DLD' period in 2. it is same in 4th record. 4th do not need as it extended (renew) in record 3
You could probably use
STR_TO_DATE
for this purpose:http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date
For instance:
The format specifiers (
%d
, etc.) are listed here:http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format