Skip to content
Prev 167876 / 398502 Next

Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates)

I believe the original thread was about whether the function returns NA or stops with an error when given an invalid date (such as Feb 29 in a non-leap year).  Your question was about how as.Date returned something different from what you expected.  Related, but different enough that it probably would have been better to start a new thread.

For your question, the help page for as.Date includes:

  "format: A character string.  The default is '"%Y-%m-%d"'.  For
          details see 'strftime'."

And 

"Character strings are processed as far as
     necessary for the format specified: any trailing characters are
     ignored."

I don't see anything in your examples that runs counter to the above.

Remember that computers do exactly what you tell them to do, not what you think that they should do.