I have a problem in getting the sum of time taken between two status of an order

I can able the get the created time by the following code:

$collection = Mage::getResourceModel('sales/order_status_history_collection')
    ->addAttributeToFilter('status', array('eq'=>'complete'))

is there a way to get the sum of time taken between two status like sum(OrderInvoiced+OrderShipped) ?

Any help would be appreciated.

  • Refer to this: magento.stackexchange.com/questions/125058/… You will need to save time in your custom table. Then you will be able to get the sum of time Apr 29, 2019 at 6:47
  • I belive all the order status and created_at time are stored in this table sales_order_status_history is there a way to sum up with this information
    – Karthik Rj
    Apr 29, 2019 at 7:29

1 Answer 1


You can check these details in this table sales_flat_order_status_history.

//Load order object using the order ID
$order->getStatusHistoryCollection(); // This will give all the status associated with the order

Find the time difference between first status and complete status will be the time taken to fulfill the order.

A minimum calculation in PHP will give you the time difference

$date1 = new DateTime('2012-06-01 02:12:51');
$date2 = $date1->diff(new DateTime('2014-05-12 11:10:00'));
echo $date2->days.'days';
echo $date2->h.' hours'."\n";
  • Its helpful thank you
    – Karthik Rj
    Apr 29, 2019 at 12:32

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.