Skip to content
Prev 26135 / 63424 Next

Date vs date

On 9/14/07, Terry Therneau <therneau at mayo.edu> wrote:
There are some other programs that use 1/1/70.  See the R Help Desk article
in R News 4/1 that discusses a few origins.
You can define as.Date.numeric in your package and then it will work.  zoo
has done that.

library(zoo)
as.Date(10)

Some other things you can do:

today <- Sys.Date()
Epoch <- today - as.numeric(today)

Epoch + 10  # similar to as.Date(10)
Note that you can write:

x <- Sys.Date()
y <- x + 1
as.numeric(x-y)
as.numeric(x) - as.numeric(y)
as.Date("09Sep2007", "%d%b%Y")