How to filter a collection with specific column name from and to in Magento2? For example:

  $fromdate = 2022-10-23 00:00:00;
  $todate  =  2022-10-25 00:00:00
  $collection = $this->productCollectionFactory->create()
                         ->addAttributeToFilter('status', 1);

How can I get the collection between $fromdate to $todate ?????

1 Answer 1


I think this will help you

addAttributeToFilter('column_name', array('from'=>'2022-10-23 00:00:00', 'to'=>'2022-10-24 00:00:00'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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