[R] How to get last day of a month?

jim holtman jholtman at gmail.com
Sun Sep 13 20:31:08 CEST 2009


Does this help.  Shows how to use the basic functions to get at the answer:

> # add first day of month to make it valid
> x <- as.POSIXct(paste('1', 'sep2009', sep=''), format="%d%b%Y")
> # now advance one month and then go back one day for the end of the month
> next.mon <- seq(x, length=2, by='1 month')[2]
> last.day <- seq(next.mon, length=2, by='-1 day')[2]
> last.day
[1] "2009-09-30 GMT"
>


On Sun, Sep 13, 2009 at 2:18 PM, megh <megh700004 at yahoo.com> wrote:
>
> Is there any R function to calculate automatically the last day of a
> particular month? For example "sep2009" should be converted to last day of
> September of 2009?
>
> Thanks
> --
> View this message in context: http://www.nabble.com/How-to-get-last-day-of-a-month--tp25425645p25425645.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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list