Count number of days between two dates
With the Date (and DateTime) classes you can do (end_date - start_date).to_i
to get the number of days difference.
Assuming that end_date
and start_date
are both of class ActiveSupport::TimeWithZone
in Rails, then you can use:
(end_date.to_date - start_date.to_date).to_i