[R] Dates and times from Excel

David Scott d.scott at auckland.ac.nz
Mon Feb 23 02:26:17 CET 2009


I have used xlsReadWrite to read data from an Excel spreadsheet.

I had a problem with converting times of the day so that I could create 
POSIXct date-time objects. I was wondering if there was a better 
solution.

Excel stores times of the day as fractions of a day so I wrote a function 
to convert the fraction to a number of seconds, extract the hours, minutes 
and seconds and output it in ISO standard format (%H:%M:%S).

Given a date obtained from an Excel date using as.Date I could then make 
up my POSIXct date-time objects.

This seems like it would be such a standard operation that there may be 
existing solutions that I have missed.

Any comments, advice?

David Scott

_________________________________________________________________
David Scott	Department of Statistics
 		The University of Auckland, PB 92019
 		Auckland 1142,    NEW ZEALAND
Phone: +64 9 373 7599 ext 85055		Fax: +64 9 373 7018
Email:	d.scott at auckland.ac.nz

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics




More information about the R-help mailing list