0

I am running into an issue and I don't know how to get through it. I am reading in an excel file in my R code. When I read in the file, the date format in some columns automatically changes into a different format compared to one that is originally in the excel file

As an example I will show you what It looks like this:

product_id  tracking_number start_date  end_date
15685       1211343131      5/21/2018   43241
15685       35164164        5/21/2018   43241
24714       5316849643      8/8/2017    43473
27608       4646435131      8/9/2017    43375
27608       531643131       8/9/2017    43375
27659       464641351       8/9/2017    43375
27659       164646131       8/9/2017    43375
38073       1684646131      1/8/2019    43957

I want the end_date to be in the similar format as the start_date but for some reason this is what comes up. Can anyone help me with this? I would really appreciate it. Thanks

r2evans
  • 141,215
  • 6
  • 77
  • 149
Jay
  • 67
  • 4
  • 1
    Can you change the `format` from excel itself – akrun Dec 28 '20 at 19:33
  • I tried that but when I read it in R it automatically changes again. – Jay Dec 28 '20 at 19:42
  • Usually, I do `format cells`, change it from excel and reload. If it is not working, then you can do `as.Date(43241, origin = '1899-12-01')# [1] "2018-04-22"` i.e. in your case, it is `as.Date(df1$end_date, origin = '1899-12-01')` – akrun Dec 28 '20 at 19:44
  • 1
    Likely dupes: https://stackoverflow.com/q/42757553/3358272, https://stackoverflow.com/q/24574939/3358272. (@akrun, one of those is yours :-) – r2evans Dec 28 '20 at 19:44

0 Answers0