Shoaibkhanz
Shoaibkhanz

Reputation: 2082

Converting excel time to R time format

When I am trying to convert csv time format into R time format using the below code, I get datetime format although i do not intend to do so.

Why and how can i avoid it?

bat2$or_time<-as.POSIXct(as.character(bob$Order_Time), format="%H:%M:%S")

enter image description here

Upvotes: 1

Views: 3010

Answers (2)

hvollmeier
hvollmeier

Reputation: 2986

enclose your expression with format( 'your expression',"%H:%M:%S") like so :

format(as.POSIXct(as.character(bob$Order_Time), format="%H:%M:%S"),"%H:%M:%S")

Upvotes: 0

Shoaibkhanz
Shoaibkhanz

Reputation: 2082

This did the Trick!

bat1$or_time<-as.POSIXlt(as.character(bat1$Order_Time), format="%H:%M:%S")
bat1$or_time<-format(bob$or_time, format="%H:%M:%S")

Upvotes: 1

Related Questions