> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Joshua Wiley
> Sent: Thursday, March 25, 2010 1:48 PM
> To: anna
> Cc: r-help@r-project.org
> Subject: Re: [R] Convert number to Date
> 
> Dear Anna,
> 
> Rolf's explanation not withstanding, it has to do with differences in
> how R and Excel treat dates.  If you use
> 
> as.Date(40182, origin="1899-12-30")
> 
> you will get the same date as Excel.  You can look at:
> 
> http://office.microsoft.com/training/training.aspx?AssetID=RC102786151033&CTT=
> 6&Origin=RP102786121033
> 
> For an official guide on how Excel dates are calculated.  Apparently,
> Excel's calendar starts on 1 January 1900.  Why one has to use an
> origin of 30 December 1899 in R...well, I suspect that gets back to
> Rolf's explanation.
> 
> 
> HTH,
> 
> Josh
> 
<<<snip>>>

The reason one must use 1899-12-30, as the origin, is 
1. Excel treats 1900-01-01 as day 1, but as.Date() teats the origin as day 0.
2. According to Wikipedia, Excel copied the Lotus 1-2-3 error of making 1900 a 
leap year (an extra day)

That accounts for the two day difference.

Hope this is helpful,

Dan 

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204

______________________________________________
R-help@r-project.org 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.

Reply via email to