How to show date column as string with specific date format like %d-%m-%y

Suppose you have POSIXct column in your data frame and you see value as 2016-01-06 19:17:38 in table view and you want to see the data in %d-%m-%Y format. So here is how you can do it.

original column

So in this example, X4 column is the one that has datetime values.

Convert and format with as.character function

you can use as.character with format argument like below.

as.character(X4, format = "%d-%m-%Y") like below.

Convertd column

This changes the X4 columns like this in (%d-%m-%Y) format.