1

I am trying to read a date format in R, but it does not handle the weekday (first thing). This is what I tried so far:

as.Date('Tue Feb  8 19:56:28 2022', format = "%a %b  %d %H:%M:%S %Y")

This works fine:

as.Date('Feb  8 19:56:28 2022', format = "%b  %d %H:%M:%S %Y")

Help appreciated.

lovalery
  • 4,524
  • 3
  • 14
  • 28
SDahm
  • 474
  • 2
  • 9
  • 21
  • I thought about using grep or sub by just killing the weekday/ the first 3 letters and the space from the string. – SDahm Feb 08 '22 at 23:36
  • 2
    I can't reproduce your problem. `as.Date('Tue Feb 8 19:56:28 2022', format = "%a %b %d %H:%M:%S %Y")` this returns "2022-02-08". I am wondering if it has something to do with your locale. Run `Sys.getlocale()` and see if it returns an English language location. – Dave2e Feb 09 '22 at 00:15
  • 1
    Yes, this made the trick: Sys.setlocale("LC_ALL","English") – SDahm Feb 09 '22 at 07:41

0 Answers0