How to convert Excel serial date to POSIXct in R (i.e. 42309 = 2015-11-01)

If you are converting a column of Excel serial dates in a dataframe:

> df$yourDates <- as.POSIXct(as.Date(df$yourDates, origin = “1899-12-30”)) [1] [POSIXct dates]

… or …

If you are converting a single Excel serial date:

> mydate = as.POSIXct(as.Date(42309, origin = “1899-12-30”))
[1] 2015-11-01

Note: This solution requires the lubridate package.

 
1
Kudos
 
1
Kudos

Now read this

How to convert a Unix timestamp to POSIXct in R (i.e. 1532289300 = 2018-07-22 19:55:00)

If you are converting a column of Unix timestamps in a dataframe: > df$Your.Times <- as.POSIXct(df$Your.Times, origin = “1970-1-1”) [1] [POSIXct datetimes] … or … If you are converting a single Unix timestamp: > yourtime =... Continue →