Search code examples
rubyactivesupport

Count number of days between two dates


How do I count the number of days between these two dates?

start_date = Date.parse "2012-03-02 14:46:21 +0100"
end_date =  Date.parse "2012-04-02 14:46:21 +0200"

Solution

  • With the Date (and DateTime) classes you can do (end_date - start_date).to_i to get the number of days difference.