The ultimate goal is to get a list of customers whose birthday is today and send them a voucher code (which is also executed programmatically).
To do this, I need all customers today to get a birthday. In SQL, I would convert date
to day and month and query this, but I'm not sure how to do this in the collection. I currently have:
$collection = Mage::getResourceModel('customer/customer_collection')
->joinAttribute('dob','customer/dob', 'entity_id');
->addAttributeToFilter('dob', '2015-10-02 00:00:00');
This only applies to people with DOB 2/10/2015. In this example, I need to match everyone with the birth date of October 2, and not just October 2, 2015. So, how can I omit the year and just include the day and month?
I was able to achieve this using LIKE, but it seems unoptimized, and I would suggest that this is a much better way to do this:
$collection = Mage::getResourceModel('customer/customer_collection')
->joinAttribute('dob','customer/dob', 'entity_id')
->addAttributeToFilter('dob', array('like' => '%-10-02 00:00:00'));