[R-SIG-Finance] extract certain date in a month

Jeff Ryan jeff.a.ryan at gmail.com
Mon Jan 7 04:32:57 CET 2008


> Dates <- as.POSIXct('2007-01-01') + (0:365)

*should read*

Dates <- as.Date('2007-01-01') + (0:365)

-OR-

Dates <- as.POSIXct('2007-01-01') + (0:365) * 86400

Sorry.
Jeff

On Jan 6, 2008 9:28 PM, Jeff Ryan <jeff.a.ryan at gmail.com> wrote:
> ShyhWeir:
>
> Dates <- as.POSIXct('2007-01-01') + (0:365)
> third.wednesdays <- which(format(Dates, "%d") > 14 & format(Dates, "%d") < 22 &
>                format(Dates, "%u") == 3)
> Dates[third.wednesdays]
>
> The last format() is the actual weekday, Monday is 1...Wed is 3
>
> You can get the last Friday (options/futures expiry) all wrapped up in
> a function in
> the package quantmod ( www.quantmod.com and on CRAN)
>
> ?options.expiry
>
> Which is where I got the code to modify.
>
> Jeff
>
>
> On Jan 6, 2008 7:21 PM, ShyhWeir Tzang <swtzang at gmail.com> wrote:
> > Dear all:
> >
> > How can I extract the date of the third Wednesday in each month? Is there
> > any available function to do it?
> > Thanks for help.
> >
> > ShyhWeir
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-SIG-Finance at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only.
> > -- If you want to post, subscribe first.
> >
>



More information about the R-SIG-Finance mailing list