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

Heinz Tuechler tuech|er @end|ng |rom gmx@@t
Wed Jun 10 10:34:37 CEST 2020


maybe
isoDates <- as.Date(oriDates, format = "%d/%m/%y")

Heinz

Luigi Marongiu wrote/hat geschrieben on/am 10.06.2020 10:20:
> 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?
>



More information about the R-help mailing list