How to convert only variables with dates stored as text to date class?

That is a problem with the way excel deals with dates, you can transform it this way

df <- tibble::tibble(other_variable = c("a", "b"),
                     `Sales of the Car produced in european (Date)` = c("43427","43116"),
                     `Product designed and Contract signed since` = c("42124", "43427")
)

df %>% 
    mutate_at(vars(matches("date|since")), ~as.Date(as.numeric(.x), origin = "1899-12-30"))
#> # A tibble: 2 x 3
#>   other_variable `Sales of the Car produced i… `Product designed and Contr…
#>   <chr>          <date>                        <date>                      
#> 1 a              2018-11-23                    2015-04-30                  
#> 2 b              2018-01-16                    2018-11-23
2 Likes

Your solution works perfectly fine.
Thanks for your time and guidance @andresrcs

Thanks @Yarnabrina, I had made mistake in interpreting how excel reads dates itself.
But thanks for your time in correcting me.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.