Reputation: 45
I have yearly time data for one year in a single file with 30 min interval such as
"01-01-2013 00:00" "01-01-2013 00:30" "01-01-2013 01:00" "01-01-2013 01:30" "01-01-2013 02:00" "01-01-2013 02:30".....
But in the entire data, some of them contains
"08-28-2013 14:53", "08-28-2013 15:37"
I need to find those from the entire record and to replace(round off) into 30 mins time interval like
"08-28-2013 15:00", "08-28-2013 15:30"
Help me in this..
Upvotes: 2
Views: 2800
Reputation: 132706
datetimes <- c("08-28-2013 14:53", "08-28-2013 15:37")
datetimes <- strptime(datetimes, "%m-%d-%Y %H:%M", tz="GMT")
datetimes$min <- round(datetimes$min / 30) * 30
#1] "2013-08-28 15:00:00 GMT" "2013-08-28 15:30:00 GMT"
Upvotes: 5