Hi, Here i have a time along with date, for eg:- "10/5/2012 5:05:00 AM" i need to do minus 10 minutes along current date Like this :- "10/5/2012 4:55:00 AM" Thanks in Advance Antony -- View this message in context: http://r.789695.n4.nabble.com/Minute-Difference-tp4645157.html Sent from the R help mailing list archive at Nabble.com.
Minute Difference
5 messages · Rantony, David Winsemius, arun +2 more
On Oct 5, 2012, at 5:56 AM, Rantony wrote:
Hi, Here i have a time along with date, for eg:- "10/5/2012 5:05:00 AM" i need to do minus 10 minutes along current date Like this :- "10/5/2012 4:55:00 AM"
There are both 'cut' and 'seq' methods for vectors of class POSIXt. These support operations that specify particular units. ?cut.POSIXt # has link to the seq method help page I am not posting code when questions fail to adhere to the reproducible code request.
David Winsemius, MD Alameda, CA, USA
Hi, Try this: date1<-"10/5/2012 5:05:00 AM" ?format(as.POSIXct(strptime(date1,format="%m/%d/%Y %H:%M:%S"))-600,format="%m/%d/%Y %r") #[1] "10/05/2012 04:55:00 AM" A.K. ----- Original Message ----- From: Rantony <antony.akkara at ge.com> To: r-help at r-project.org Cc: Sent: Friday, October 5, 2012 8:56 AM Subject: [R] Minute Difference Hi, Here i have a time along with date, for eg:-? "10/5/2012 5:05:00 AM" i need to do minus 10 minutes along current date Like this :- "10/5/2012 4:55:00 AM" Thanks in Advance Antony -- View this message in context: http://r.789695.n4.nabble.com/Minute-Difference-tp4645157.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
Mr Rantony could also probably benefit from taking a look at the lubridate package. Cheers, Michael
On Fri, Oct 5, 2012 at 8:04 PM, arun <smartpink111 at yahoo.com> wrote:
Hi, Try this: date1<-"10/5/2012 5:05:00 AM" format(as.POSIXct(strptime(date1,format="%m/%d/%Y %H:%M:%S"))-600,format="%m/%d/%Y %r") #[1] "10/05/2012 04:55:00 AM" A.K. ----- Original Message ----- From: Rantony <antony.akkara at ge.com> To: r-help at r-project.org Cc: Sent: Friday, October 5, 2012 8:56 AM Subject: [R] Minute Difference Hi, Here i have a time along with date, for eg:- "10/5/2012 5:05:00 AM" i need to do minus 10 minutes along current date Like this :- "10/5/2012 4:55:00 AM" Thanks in Advance Antony
On 10/05/2012 10:56 PM, Rantony wrote:
Hi, Here i have a time along with date, for eg:- "10/5/2012 5:05:00 AM" i need to do minus 10 minutes along current date Like this :- "10/5/2012 4:55:00 AM"
Hi Antony,
Did you get an answer for this?
oldtime<-strptime("10/5/2012 5:05:00 AM",
format="%d/%m/%Y %I:%M:%S %p")
oldtime
[1] "2012-05-10 05:05:00"
# now subtract 10 minutes (600 seconds)
oldtime - 600
[1] "2012-05-10 04:55:00 EST"
Jim