Skip to content
Prev 380033 / 398500 Next

Separating Date and Time

R-Help

 

I'm using the following code to deparate the date and time components from a
date_time varaible as follows:

 

dt1$date <- format(as.POSIXct(dt1$date_time, format = "%m/%d/%Y %H:%M"),
"%Y-%m-%d")

dt1$time <- format(as.POSIXct(dt1$date_time, format = "%m/%d/%Y %H:%M"),
"%H:%M:%S")

 

But I end up with <chr> objects. What am I missing?

 

Jeff