Suresh_FSFM
2009-Feb-03 19:48 UTC
[R] How to subtract 2 days from a variable storing particular date
Dear R- Exerts, Seek your help. Suppose I have a variable "X" that stores a date: "2008-12-15 CET" Now, I want to subtract 2 days (better two working days) from value stored in "X". Please let me know how to do so. Another variable "Y" stores timestamp as: 2008-11-28 00:09:00 I want to subtract 2 days from "Y". How to perfrm this subtraction? Thank you in advance. Regards, Suresh -- View this message in context: http://www.nabble.com/How-to-subtract-2-days-from-a-variable-storing-particular-date-tp21817414p21817414.html Sent from the R help mailing list archive at Nabble.com.
Gabor Grothendieck
2009-Feb-03 19:54 UTC
[R] How to subtract 2 days from a variable storing particular date
Try this: now <- Sys.time() seq(now, length = 2, by = "-2 days")[2] and see R News 4/1 for more on dates. On Tue, Feb 3, 2009 at 2:48 PM, Suresh_FSFM <suresh.ghalsasi at gmail.com> wrote:> > Dear R- Exerts, > Seek your help. > > Suppose I have a variable "X" that stores a date: "2008-12-15 CET" > Now, I want to subtract 2 days (better two working days) from value stored > in "X". > Please let me know how to do so. > > Another variable "Y" stores timestamp as: 2008-11-28 00:09:00 > I want to subtract 2 days from "Y". > How to perfrm this subtraction? > > Thank you in advance. > > Regards, > Suresh > > > > > > -- > View this message in context: http://www.nabble.com/How-to-subtract-2-days-from-a-variable-storing-particular-date-tp21817414p21817414.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. >
Suresh_FSFM
2009-Feb-03 20:09 UTC
[R] How to subtract 2 days from a variable storing particular date
Great ! Thanks a lot for prompt and positive response. Best Regards, Suresh Gabor Grothendieck wrote:> > Try this: > > now <- Sys.time() > seq(now, length = 2, by = "-2 days")[2] > > and see R News 4/1 for more on dates. > > > On Tue, Feb 3, 2009 at 2:48 PM, Suresh_FSFM <suresh.ghalsasi at gmail.com> > wrote: >> >> Dear R- Exerts, >> Seek your help. >> >> Suppose I have a variable "X" that stores a date: "2008-12-15 CET" >> Now, I want to subtract 2 days (better two working days) from value >> stored >> in "X". >> Please let me know how to do so. >> >> Another variable "Y" stores timestamp as: 2008-11-28 00:09:00 >> I want to subtract 2 days from "Y". >> How to perfrm this subtraction? >> >> Thank you in advance. >> >> Regards, >> Suresh >> >> >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/How-to-subtract-2-days-from-a-variable-storing-particular-date-tp21817414p21817414.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. >> > > ______________________________________________ > 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. > >-- View this message in context: http://www.nabble.com/How-to-subtract-2-days-from-a-variable-storing-particular-date-tp21817414p21817818.html Sent from the R help mailing list archive at Nabble.com.