[R-SIG-Finance] Passing dates from Excel to R using RExcel functions
Brian G. Peterson
brian at braverock.com
Mon Sep 11 13:58:51 CEST 2006
On Monday 11 September 2006 03:42, Paolo Rossi wrote:
> I have the following problem using RExcel. When I use the VBA function
> "putarray" to put a vector of dates from Excel to R, I don't see the
> dates in R but the serial number converted to text. I don't know, then,
> how to trasform them in dates again...
>
> could anyone help me?
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
More information about the R-SIG-Finance
mailing list