I have one column in data frame contains date and time stamp , below is sample data which is available in that column
Date
03-31-2016 23:25:13:13
03-31-2016 21:02:51:51
03-31-2016 20:58:31:31
03-31-2016 19:37:43:43
03-31-2016 19:15:29:29
03-31-2016 18:40:10:10
03-31-2016 18:23:39:39
03-31-2016 17:39:06:06
03-31-2016 17:36:33:33
When I tried to convert above column to date in r using below syntax it converting all values to NA, can anyone help me how I can convert above column to date format I need only day/month/year in that column
complete$Date <- as.Date(complete$Date, format = "%Y-%m-%d")
The data format
you're trying is wrong! It's month first and then day and then year
complete$Date <- as.Date(complete$Date, format = "%m-%d-%Y")