[R] How to convert European short dates to ISO format?

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Wed Jun 10 16:37:23 CEST 2020


Fix your format specification?

?strptime

On June 10, 2020 1:20:01 AM PDT, Luigi Marongiu <marongiu.luigi using gmail.com> wrote:
>Hello,
>I have been trying to convert European short dates formatted as
>dd/mm/yy into the ISO 8601 but the function as.Dates interprets them
>as American ones (mm/dd/yy), thus I get:
>
>```
>oriDates = c("23/01/20", "24/01/20", "25/01/20", "26/01/20",
>"27/01/20", "28/01/20", "29/01/20", "30/01/20",
>             "31/01/20", "01/02/20", "02/02/20", "03/02/20",
>"04/02/20", "05/02/20", "06/02/20", "07/02/20")
>isoDates = as.Date(oriDates, format = "%m/%d/%y")
>> isoDates
> [1] NA           NA           NA           NA           NA
>NA           NA
> [8] NA           NA           "2020-01-02" "2020-02-02" "2020-03-02"
>"2020-04-02" "2020-05-02"
>[15] "2020-06-02" "2020-07-02"
>```
>
>How can I convert properly?

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list