1

I have the following code:

SELECT DOB as mydate,'Birthday' as event, clients.* 
FROM `clients` WHERE 
DATE_FORMAT(`DOB`, '%m%d') 
BETWEEN DATE_FORMAT('".date("Y-m-d",strtotime($_POST['textfield1']))."', '%m%d') 
AND DATE_FORMAT('".date("Y-m-d",strtotime($_POST['textfield2']))."', '%m%d') 
ORDER BY DATE_FORMAT(`DOB`, '%m%d') ASC";

Which works fine if textfield2 is a month that comes after textfield1 (ie November comes after July) but doesn't work when trying to search for dates between November and July.

For example I am trying to search for all birthdays between November 2014 and July 2015, what do I need to change in my code for this search to work?

LABCAT
  • 11
  • 1

0 Answers0