Henaff,

I have found the following to be of use when using Date manipulations.

Example:

 tDate <- as.Date("03/22/2006", "%m/%d/%Y") ;

tDate +1    ## will give the update 03/23/2006 and so on..

Best regards,

Mahesh.

ps: fyi: the capital Y in as.Date refers to a 4 digit year representation


On 3/21/06, P. Hénaff <patrick.henaff@kermatheano.com> wrote:
>
> I'm a rank beginner in R and R-metrics, but experienced in matlab and
> other languages. I'm strugling with date arithmetics in R. I'm doing
> statistical analysis on financial time series, using its, which uses POSIXct
> objects to measure time. What is the best way to perform simple date
> arithmetic with these objects? I do not care about h/m/s, nor do I care
> about daylight saving time. Example of a problem I faced:
>
> Add one day to 3-apr-2005. (daylight saving starts on 4-apr-2005).
> If I do
> > as.POSIXct("2005-04-03") + 86400
> I get 1 a.m. on the 4th of april.
>
> So, I do something like
> > dt1 <- as.POSIXct("2005-04-03")
> > x1 <- timeDate(dt1)
> > x2 <- timeNdayOnOrAfter(x1, n=2)
> > dt2 <- as.POSIXct(as.POSIXlt(x2))
>
> There has to be something simpler!
>
> Another problem. The tseries and timeDate packages seem to require that
> one changes his timezone environment variable to GMT. This is not really
> possible in a corporate environment. Is there a work-around?
>
> Any help will be much appreciated.
>
> Patrick Henaff
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-finance@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>

	[[alternative HTML version deleted]]

