'How to reformat dates without NA's
I have a column of dates I need to reformat, they are in the format m/d/yyyy, but as the dates grow the format becomes mm/dd/yyyy. When I try to run
as.Date(x, format = '%m/%d/%y')
I get NA's
How can I reformat the dates to mm/dd/yyyy?
Solution 1:[1]
Here is an example:
# convert date info in format 'mm/dd/yyyy'
strDates <- c("01/05/1965", "08/16/1975")
strDates
Output:
[1] "01/05/1965" "08/16/1975"
Convert the dates using this code:
dates <- as.Date(strDates, "%m/%d/%Y")
Output:
[1] "1965-01-05" "1975-08-16"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Quinten |
