Get Started →
Date & Time Errors

Character not in standard date format

Matches: character string is not in a standard unambiguous format

WHAT THIS ERROR MEANS

as.Date() or as.POSIXct() can't automatically parse your date string because it doesn't match the default format (YYYY-MM-DD). You need to specify the format explicitly.

HOW TO FIX IT

1. Specify the format: as.Date(x, format = '%m/%d/%Y').

2. Use lubridate functions for easier parsing: mdy(), dmy().

3. Common format codes: %Y=4-digit year, %m=month, %d=day.

CODE EXAMPLES

BAD — THIS CAUSES THE ERROR
as.Date("03/15/2024")  # ambiguous format
GOOD — CORRECT APPROACH
as.Date("03/15/2024", format = "%m/%d/%Y")
# or
lubridate::mdy("03/15/2024")

Still stuck?

Paste your code in RChat and the AI will fix this error in context.

Try RChat Free →

RELATED DATE & TIME ERRORS