Would like to change the date format. My data frame is shown below and would like to change all the date formats to "%d/%m/%Y"
.
df:
id bdate wdate ddate 1 09/09/09 12/10/09 2009-09-27
We change the date format from one format to another. For example - we have stored date in MM-DD-YYYY format in a variable, and we want to change it to DD-MM-YYYY format. We can achieve this conversion by using strtotime() and date() function.
To format = , provide a character string (in quotes) that represents the current date format using the special “strptime” abbreviations below. For example, if your character dates are currently in the format “DD/MM/YYYY”, like “24/04/1968”, then you would use format = "%d/%m/%Y" to convert the values into dates.
df$ddate <- format(as.Date(df$ddate), "%d/%m/%Y")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With