Skip to content

Passing dates from Excel to R using RExcel functions

4 messages · Paolo Rossi, Brian G. Peterson, Gabor Grothendieck +1 more

#
On Monday 11 September 2006 03:42, Paolo Rossi wrote:
Excel denominates dates in days since 1 Jan 1970.  You need to convert 
those to a unix timestamp, and then convert them to a Date class in R.

I've never specifically had this problem directly in R, but I do have some 
PHP code that you should be able to adapt to R to solve your problem.

if ($passed_date<2958465) { //this is an MS Excel date
    //MS Excel denominates in days since 1 Jan 1970
    $ts = ($passed_date - 25568) * 86400;
    $formatted_date  = date ( 'Y-m-d' , $ts);
}


Hope this helps,

   - Brian
#
There is some discussion of Excel dates in the R Help article
in R News 4/1.
On 9/11/06, Paolo Rossi <prossi79.r at gmail.com> wrote:
2 days later
#
I have had no problems passing date in as dataframes back and forth and 
is now my prefered method..  No need to even do as.Date or know
all the Posixct kungfu although it is worth knowing all that..
[Instead of  rput I use rputdataframe and this works like a charm with 
zoo or the new Diethelm's timeSeries class .]


Best,
Krishna
Gabor Grothendieck wrote: