I subtracted two dates in excel and forma the difference as hh:mm:ss and showing correctli in excel file , however while importing it changes to 1904-01-21 03:18:35 .
how can get back time only from this in R
needs accuaate time as needed
CodePudding user response:
We could use format
after converting to Datetime
format(as.POSIXct(df1$Date), "%H:%M:%S")
CodePudding user response:
Adding to @akrun's answer, there's a shorthand for the time portion of a date, %T
strftime(as.POSIXct(c("1904-01-21 03:18:35")), format="%T")
[1] "03:18:35"