[R-SIG-Finance] Relative Date Question

Peter Carl peter at braverock.com
Thu Aug 28 14:02:13 CEST 2008


On Thursday 28 August 2008 4:14:58 am Ruvashen Padayachee wrote:
> For example, how can I find the date one month after "2008/09/30" ?

The class 'Date' provides a 'seq.Date' function for creating date sequences.
> seq(as.Date("2008-09-01"),length.out=12, by="1 month")
> seq(ISOdate(2008,9,30), by = "month", length = 4)

Note that this second example, which attempts to create a sequence of 
end-of-month dates, doesn't work very well.  How to find last day of the 
month in a date sequence?  Unfortunately, the solution is so trivial that it 
might not be obvious.

> seq(as.Date("2008-9-01"),length.out=4, by="1 month")-1

HTH

pcc
-- 
Peter Carl
145 Scottswood Rd
Riverside, IL 60546
312 307 6346
http://www.braverock.com/~peter



More information about the R-SIG-Finance mailing list