Hi Jeff, Well, the output of "format" is character strings, so that is what you are missing. I assume that you want to get two numeric values for each date.
date1<-"06/20/2019 09:07" > as.POSIXct(date1,format="%m/%d/%Y %H:%M") [1] "2019-06-20 09:07:00 AEST" day<-as.numeric(as.POSIXct(date1,format="%m/%d/%Y")) day [1] 1560952800 seconds<-as.numeric(as.POSIXct(date1,format="%m/%d/%Y %H:%M"))-day seconds [1] 32820 Jim On Thu, Jun 20, 2019 at 8:13 AM <reichm...@sbcglobal.net> wrote: > > 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 > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.