0

I have an excel spreadsheet that has different date formats. R reads in the dates correctly when they're formatted as m/dd/yy, but when they're m/d/yy, it reads them as a code like this: 36251.

To fix it, I found this, which seems useful, but it is only for one date and I have multiple.

How to convert Excel date format to proper date in R

This was what was suggested:

as.Date(42705, origin = "1899-12-30")

So I tried this:

stockindices0$Date <- as.Date(stockindices0$Date , origin = "12-30-99")

but got the error:

Error in charToDate(x) : 
  character string is not in a standard unambiguous format

I also tried it with the year as 1899 with no success.

bandcar
  • 649
  • 4
  • 11

1 Answers1

0

You can try this

as.Date(stockindices0$Date, format = "%d/%m/%y")
amanwebb
  • 380
  • 2
  • 9