Search code examples
rdifftime

Difference between dates not a whole number


Why is this not giving me a whole number of days?

difftime("2015-04-22", "2014-10-30")

Time difference of 173.9583 days

Solution

  • Use the Date class to avoid the extra complexity of timestamps, daylight savings time, etc.

    > as.Date("2015-04-22") - as.Date("2014-10-30")
    Time difference of 174 days