lubridate (version 0.1)

subtract_dates: Subtraction for the duration (i...

Description

Subtraction for the duration (i.e, difftime), period, and interval classes.

Usage

subtract_dates(e1, e2)

Arguments

e1
a duration(i.e. difftime), period, interval, POSIXt, or Date object
e2
a duration(i.e. difftime), period, interval, POSIXt, or Date object

Value

  • a new duration(i.e. difftime), period, interval, POSIXt, or Date object, depending on e1 and e2

Details

The subtraction methods returns an interval object when a POSIXt or Date object is subtracted from another POSIXt or Date object. To retrieve this difference as a difftime, use as.duration. To retrieve it as a period use as.period.

Since a specific number of seconds exists between two dates, the duration returned will not include unspecific time units such as years and months. See duration for more details.

Examples

Run this code
x <- new_duration(day = 1)
now() - x
-x
x - x
as.Date("2009-08-02") - as.Date("2008-11-25")

Run the code above in your browser using DataCamp Workspace