Question: ```
D <- "06.12.1948"                 # which is dd.mm.yyyy
as.Date(D, "%d.%m.%y")            # convert to date
[1] "2019-12-06"                  # ????    

```

what is it that I am missing?

> 
> Sys.getlocale(category = "LC\_ALL")
>  [1] "LC\_COLLATE=German\_Austria.1252;LC\_CTYPE=German\_Austria.1252;LC\_MONETARY=German\_Austria.1252;LC\_NUMERIC=C;LC\_TIME=German\_Austria.1252"
> 
> 
>

Answer: 
To avoid remembering formats of the date we can use packaged solutions. 

1) With `lubridate`

```
lubridate::dmy(D)
#[1] "1948-12-06"

```

2) Using `anytime`

```
anytime::anydate(D)
#[1] "1948-06-12"

```
Lubridate is the best option for this in my opinion. The following will work fine.

```
`data %>% mutate(date_variable = as.Date(dmy(date_variable)))`

```

Interestingly though I found dmy() to behave weirdly when as.Date() and dmy() were called in separate steps