[R] Dates in R

Thomas Lumley thomas at biostat.washington.edu
Mon Feb 14 20:53:27 CET 2000


On Mon, 14 Feb 2000, Richard A. Bilonick wrote:

> Hi,
> 
> My dates are printing as 01/01/100 instead of 01/01/2000. I can't find a way to
> get mm/dd/yyyy type format. I've installed both chron and date.
> 

This shouldn't happen with date unless you actually specify the date as
100CE rather than 2000CE.

I get
R> d1<-as.date("14 Feb 2000")
R> d2<-as.date("2/14/2000")
R> d3<-mdy.date(2,14,2000)
R> d1
[1] 14Feb2000
R> d2
[1] 14Feb2000
R> d3
[1] 14Feb2000
R> date.mmddyy(d1)
[1] "2/14/2000"
R> date.mmddyy(d2)
[1] "2/14/2000"
R> date.mmddyy(d3)
[1] "2/14/2000"
R> date.mmddyyyy(d1)
[1] "2/14/2000"

In fact, as the default is to treat two-digit years as being in the 20th
century you even get
R> as.date("31Dec99")+1
[1] 1Jan2000


I don't know about chron, though.


	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list