-1

I have a csv file where the date is stored in mm/dd/yyyy format 8/18/2015 12:23:57 PM. When I import this file, it gets imported in string format.

How to convert this to datetime value after importing? I tried to convert while importing, but all the values were as NA.

zx8754
  • 46,390
  • 10
  • 104
  • 180
Kumar
  • 91
  • 6

1 Answers1

2

We can do this with POSIXct

as.POSIXct(str1, format = "%m/%d/%Y %I:%M:%S %p")

data

str1 <- "8/18/2015 12:23:57 PM"
akrun
  • 789,025
  • 32
  • 460
  • 575