How to Convert Date to Character in R

Here are two ways to convert Date to Character in R:

  1. Using the as.character() function
  2. Using the format() function

Method 1: Using the as.character() function

To convert a Date to a Character in R, you can use the “as.character()” or “format()” function.

dates <- c("11/20/80", "11/20/91", "11/20/1993", "09/10/93")
dt <- as.Date(dates, "%m/%d/%y")
strDates <- as.character(dt)


[1] "1980-11-20"  "1991-11-20"  "2019-11-20"  "1993-09-10"

Method 2: Using the format() function

You can also convert date to character strings using the “format()” function.

today <- Sys.Date()

format(Sys.Date(), format = "%d %B, %Y")

format(Sys.Date(), format = "Today is a %A!")


[1] "24 May, 2023"
[1] "Today is a Wednesday!"

You can see that we get the date in the character format.

That’s it.

Leave a Comment