trying to compare two strings in the form of mm/dd
Posted: Wed Mar 21, 2012 4:30 pm
Hello all,
I have a database which contains a field with a string representing a birth date called bdate. The string in the form of mm/dd/yyyy. No doubt that is certainly not the best, but that is how db was setup. DB contains over 60k records. Trying to setup function where the user pics two dates and gets back birthdays between date1 and date2, without regard to year. EX: user pics March 29th and July 16 and function displays all birthdays which are between the two.
1. first, can php meaningfully compare two strings in the form of mm/dd?
If that is the case, am thinking
query = "SELECT conum, lname, fname, bdate, address, city, state, zip FROM constituents WHERE SUBSTRING_INDEX(bdate, '/', 2) >= '$date1' AND SUBSTRING_INDEX(bdate, '/', 2) =< '$date2'";
Any suggestions would be appreciated.
I have a database which contains a field with a string representing a birth date called bdate. The string in the form of mm/dd/yyyy. No doubt that is certainly not the best, but that is how db was setup. DB contains over 60k records. Trying to setup function where the user pics two dates and gets back birthdays between date1 and date2, without regard to year. EX: user pics March 29th and July 16 and function displays all birthdays which are between the two.
1. first, can php meaningfully compare two strings in the form of mm/dd?
If that is the case, am thinking
query = "SELECT conum, lname, fname, bdate, address, city, state, zip FROM constituents WHERE SUBSTRING_INDEX(bdate, '/', 2) >= '$date1' AND SUBSTRING_INDEX(bdate, '/', 2) =< '$date2'";
Any suggestions would be appreciated.