I have a 10-column XLS file, with 2 date fields. As far as I can tell, they were configured identically in Excel 2010. One of these fields resembles "39406.577662037", whilst in Excel, it is shown as "2007-11-20 13:42:20". Applying as.Date() with the default format doesn't do it. Any ideas as to what format this is? Many thanks! -- H -- Sent from my mobile device Envoyait de mon portable
If all else fails, read the help page. There are examples on ?as.Date of reading Excel dates. But I don't believe the time you give. (0.577662037 is just before 13:51:50). On Tue, 29 Nov 2011, Hasan Diwan wrote:> I have a 10-column XLS file, with 2 date fields. As far as I can tell, > they were configured identically in Excel 2010. One of these fields > resembles "39406.577662037", whilst in Excel, it is shown as > "2007-11-20 13:42:20". Applying as.Date() with the default format > doesn't do it. Any ideas as to what format this is? Many thanks! -- H-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
You haven't indicated how you are accessing the Excel file, or whether it is
an XLS or XLSX file. It sounds like you might be using rcom or a dependent
package, in which case you may need to read the Excel COM interface
documentation more carefully. In any event, you can't expect as.Date to
understand the floating-point numbers as if they were formatted dates it they
aren't.
For my part, I highly recommend exporting to CSV before importing to R.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Hasan Diwan <hasan.diwan at gmail.com> wrote:
>I have a 10-column XLS file, with 2 date fields. As far as I can tell,
>they were configured identically in Excel 2010. One of these fields
>resembles "39406.577662037", whilst in Excel, it is shown as
>"2007-11-20 13:42:20". Applying as.Date() with the default format
>doesn't do it. Any ideas as to what format this is? Many thanks! -- H
>
>--
>Sent from my mobile device
>Envoyait de mon portable
>
>______________________________________________
>R-help at 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.