Back
In R programming, you can easily convert to standard date class and then use format to get data in desired format.
format(as.Date('3/28/2020', '%m/%d/%Y'), '%d/%m/%Y')#[1] "28/03/2020"
format(as.Date('3/28/2020', '%m/%d/%Y'), '%d/%m/%Y')
#[1] "28/03/2020"
To Convert the date from mm/dd/YYYY to dd/mm/YYYY in R.
First, start with your date in the form of mm/dd/YYYY
Then take the character vector and convert it to Date by using as.Date
Third, convert the Date to a character string by applying format on the Date.
Create a character vector filled with dates:
dates_mm_dd <- c("12/25/2024", "01/01/2024", "07/04/2024")
Convert to Date, format to dd/mm/YYYY:
dates_dd_mm <- format(as.Date(dates_mm_dd, format = "%m/%d/%Y"), format = "%d/%m/%Y")
Print the converted date
print(dates_dd_mm)
The code above converts dates to proper format and prints.
31k questions
32.8k answers
501 comments
693 users