This question already has an answer here:

I have a custom attribute called customer_products_changedate it saves the date when I link a product to it and it's linked to the customer.

How do I get the customers, filtered by that attribute, but only if the date in the attribute is older than 14 days.

I currently have this:

$collection = Mage::getResourceModel('customer/customer_collection');
$collection->addAttributeToFilter('customer_products_changedate', 'OLDER THAN 14 DAYS');

Would also be nice how to do delete those attributes than, not the users, just those attribute entries.

marked as duplicate by sv3n, Keyur Shah, Siarhey Uchukhlebau, Prince Patel, liyakat Jul 21 '17 at 6:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • It's not a duplicate, because how are we supposed to know what the difference between gt and lt is? – Arnold Jul 20 '17 at 13:29
  • I think this doesnt makes a difference. lt is less than and gt is greater then. However ... you found a solution for this :) – sv3n Jul 20 '17 at 13:35
  • 1
    Yes I agree, but still... There is no documentation of Magento. So I think questions like these will make Magento more accessible to people that are new to Magento. There are also many different variations of this question (PHP) at Stackoverflow. how to filter dates, older, newer, in a range. ect. ect. Why shouldn't it be the same with Magento? – Arnold Jul 20 '17 at 13:37
  • Ok, no wonder Magento.stackexchange sucks so much. they remove usefull questions. lol. – Arnold Jul 21 '17 at 7:17
  • It sucks so much that people help others for free? Ahh, ok. Your last questions were answered within a hour .... and it's not removed, just flagged as duplicate ... – sv3n Jul 21 '17 at 8:23

Get the date which was 14 days ago.

$date = date('Y-m-d', strtotime('-14 day'));

Now filter the collection with the date.

  • Thank you, can you also tell me how to delete those customer_products_changedate from that customer? – Arnold Jul 20 '17 at 12:38
  • What value you want to save instead of the already present date? You can load the customer and change field value and save the customer. – amitshree Jul 20 '17 at 12:42

Get date

$to= Mage::app()->getLocale()->date()->sub(14,Zend_Date::DAY);

Add that in filter:


Not the answer you're looking for? Browse other questions tagged or ask your own question.