Search code examples
rexcelreadxl

Converting numbers back to Date object in R


I am reading an Excel file using the function readxl::read_excel(), but it appears that date are not getting read properly.

In the original file, one such date is 2020-JUL-13, but it is getting read as 44025.

Is there any way to get back the original date variable as in the original file?

Any pointer is very appreciated.

Thanks,


Solution

  • You can use openxlsx package to convert number to date like

    library(openxlsx)
    
    convertToDate("44025")
    

    Or to convert the whole column you can use

    convertToDate(df$date)