I am trying to convert a character field into a date field for which the options are to either use strptime
function or as.Date
function. Here is two reproducible examples:
strptime(c("5/13/2015"),"%m/%d/%y")
#result is "2020-05-13 MST"
as.Date(c("5/13/2015"), format = "%m/%d/%y")
#result is "2020-05-13"
Why did the functions change the year from 2015 to 2020? If instead, I format my date string and use the as.Date function it works. Here is what I did:
as.Date(c("2015/5/13"))
and it works fine.
any thoughts?