I'm trying to count all the records between 2 dates that are finished. This means that the created_at field is between start_date and end_date and the finished_at field is not null.
I can use the following expression to get the records that didn't finish:
Record.count(:all, :conditions => {:created_at => start_date..end_date, :finished_at => nil })
Is there a similar way to count the records where finished at is not nil?
This should work just fine unless I'm missing something.
Record.where(:created_at => start_date..end_date).where('finished_at IS NOT NULL').count
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With