The standard answer is to use
> as.POSIXlt("2007-05-14") - as.POSIXlt("1950-01-01")
Time difference of 20952 days
If you want to ensure the time difference is in daily units, then
> difftime(as.POSIXlt("2007-05-14"),
as.POSIXlt("1950-01-01"), units = "days")
Time difference of 20952 days
If you want to use the answer in numerical computations, then one more
coercion is usually needed
> as.numeric(difftime(as.POSIXlt("2007-05-14"),
as.POSIXlt("1950-01-01"), units =
"days"))
[1] 20952
Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary): +61 7 3826 7304
Mobile: (I don't have one!)
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of threshold
Sent: Monday, 14 May 2007 7:16 PM
To: [email protected]
Subject: [R] number of days
Hi, some of you knows how to calculate in R the number of days between
given
dates?
issue relevant in option pricing
thanks, robert
--
View this message in context:
http://www.nabble.com/number-of-days-tf3751163.html#a10600371
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.