I am trying to figure out a way to add a certain number of hours to a date/time stamp. Specifically, I have a string of date/time stamps that all have the time at midnight. I would like to be able to keep the date the same, but add a certain number of hours to create a new timestamp that is a few hours later.
Below is the procedure I have tried so far with no luck: startDate <- "2008-11-01" endDate <- "2008-11-05" OutDates <- seq(as.Date(startDate), as.Date(endDate), by="day") > OutDates "2008-11-01" "2008-11-02" "2008-11-03" "2008-11-04" "2008-11-05" FourOclock <- as.difftime("16:00:00") > FourOclock Time difference of 16 hours Afternoons <- OutDates + FourOclock > Afternoons "2008-11-17" "2008-11-18" "2008-11-19" "2008-11-20" "2008-11-21" Gives the wrong answer, adding 16 days instead of 16 hours, and throws the following warning: Warning message: Incompatible methods ("+.Date", "Ops.difftime") for "+" I am stumped on this one and would appreciate any/all recommendations. Thanks! [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list 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.