Reputation: 1925
I have these numbers:
-44384.520833333299 (to datetime). It should be 07/07/2021 12:30:00
-44384 (to date). It should be 07/07/2021
How can I convert these numbers and a list of them in R?
Upvotes: 0
Views: 385
Reputation: 25313
Another possibility, using lubridate
:
library(lubridate)
# The first argument must be in seconds
as_datetime(3600*24*44384.520833333299, origin="1899-12-30")
#> [1] "2021-07-07 12:29:59 UTC"
as_date(44384, origin="1899-12-30")
#> [1] "2021-07-07"
Upvotes: 0
Reputation: 27732
openxlsx::convertToDateTime(44384.520833333299)
# [1] "2021-07-07 12:30:00 CEST"
openxlsx::convertToDate(44384)
# [1] "2021-07-07"
Upvotes: 2