2

I try to change the format of "20FEB12:00:00:00" to Date and R gives me "NA" Don´t know what I am doing wrong:

strptime("20FEB12:00:00:00", "%d%b%y:%H:%M:%S")

Thanks!

Erik Martinez
  • 23
  • 1
  • 4
  • `strptime("20FEB12:00:00:00", "%d%b%y:%H:%M:%S") [1] "2012-02-20 EST"` Double-check for typos. – Pierre L Aug 25 '15 at 15:54
  • I try but I get the same: x <- "20FEB12:00:00:00" strptime(x, format="%d%b%y:%T") [1] NA :S – Erik Martinez Aug 25 '15 at 15:57
  • There may be some issue with your session/version/OS, because your original code works fine. – Pierre L Aug 25 '15 at 15:59
  • Bufff Ok, at least the code is ok, thanks to check with me! I can not do the "check" to your answer.. :/ – Erik Martinez Aug 25 '15 at 16:01
  • The code works for me too. The description for "%b" is "Abbreviated month name in the current locale on this platform". When you run `Sys.getlocale()`, does it return a place where "FEB" represents the 2nd month? – wibeasley Aug 25 '15 at 16:12
  • Most likely the problem is with the `locale`. The abbreviated name you are using are in Spanish. There was ax exactly similar question days ago. [Here](http://stackoverflow.com/questions/32057148/r-read-abbreviated-month-form-a-date-that-is-not-in-english/32068524#32068524) is that post with a solution of mine that should do your job. – SabDeM Aug 25 '15 at 16:29
  • Sorry If I am a bit confused I have never seen this before... uhmmm if I run the Sys.getlocale() I get...... "LC_COLLATE=Spanish_Spain.1252;LC_CTYPE=Spanish_Spain.1252;LC_MONETARY=Spanish_Spain.1252;LC_NUMERIC=C;LC_TIME=Spanish_Spain.1252" – Erik Martinez Aug 25 '15 at 16:39
  • Warning message: In Sys.setlocale(locale = "es_ES.UTF-8") : OS reports request to set locale to "es_ES.UTF-8" cannot be honored – Erik Martinez Aug 25 '15 at 16:49
  • As @SabDeM recommended in the other post, try `Sys.setlocale(locale = "en_US.UTF-8")`. Are you trying to match Spanish or English months? I can't tell from "FEB". In your dataset, what string is used to represent the 1st and 12th month? – wibeasley Aug 25 '15 at 16:53
  • English months. I try with Sys.setlocale(locale = "en_US.UTF-8") – Erik Martinez Aug 25 '15 at 16:55
  • and while you're at it, try the `lubridate` package. – Carl Witthoft Aug 25 '15 at 16:56

1 Answers1

0

Sys.setlocale(category = "LC_TIME",locale = "C")

Erik Martinez
  • 23
  • 1
  • 4