To convert Excel Date format to Date and Time format in Rstudio

I have this type of format in EXCEL Date and Time

:Captura de Pantalla 2020-05-24 a la(s) 20.35.14

but when I open it in Rstudio those number become "43972.977083333331", please help me. How can i convert those numbers into a DATE AND TIME format?....

Thanks

It looks like those are numeric representations in days since Jan 1, 1900 so try something like this

my_time <- as.Date.numeric(43972.977083333331, origin = '1900-01-01')

The help file for as.Date.numeric has a lot more information

?as.Date.numeric

Hi Phil, it worked, like this:
as.Date.numeric(43972.977083333331, origin = '1900-01-01')
[1] "2020-05-23

but I need the "Time" too, How can i do this?, like this:
[1] "2020-05-23 20:00

¿How can I do this?

Sorry I missed this on first read

R provides several options for dealing with date and date/time data. The builtin as.Date function handles dates (without times); the contributed library chron handles dates and times, but does not control for time zones; and the POSIXct and POSIXlt classes allow for dates and times with control for time zones.

https://www.stat.berkeley.edu/~s133/dates.html

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.