Search code examples
mysqlzend-frameworkdatezend-db

use part of string in query


i have a mysql table with date of birth, so an example field would be:

dob
----
1989-01-01

I have pulled todays date in zend framework with the following code:

public function todaysDate()
    {
        $date = new Zend_Date();
        $date = $date->get(Zend_Date::MONTH_SHORT . '-' . Zend_Date::DAY_SHORT);
        return $date;
    }

This shows current date in format:

9-24

Now i want to search the dob field in my mysql table for anyway with the month 9 and day 24 in their dob disregarding year. how do i do this?

please note the dob is not a date field, its a text field


Solution

  • SELECT ...
    FROM ...
    WHERE (month(dob) = 9) AND (day(dob) = 24)