Re: [R] given a mid-month date, get the month-end date

From: jim holtman <jholtman_at_gmail.com>
Date: Tue 20 Dec 2005 - 03:09:27 EST

Here is one way using POSIX: (you can create a function to do this)

> x <- as.POSIXlt('2005-12-16') # a date
> x

[1] "2005-12-16"
> dput(x) #structure of the date

structure(list(sec = 0, min = 0, hour = 0, mday = 16, mon = 11,

    year = 105, wday = 5, yday = 349, isdst = 0), .Names = c("sec", "min", "hour", "mday", "mon", "year", "wday", "yday", "isdst" ), class = c("POSIXt", "POSIXlt"))
> x$mday <- 1 # reset to first of the month
> seq(x, by='month', length=2)[2] # select 2nd number in the sequence
[1] "2006-01-01 EST"
>

On 12/19/05, t c <quantpm@yahoo.com> wrote:
>
> I have a vector of dates.
>
> I wish to find the month end date for each.
>
> Any suggestions?
>
> e.g.
>
> For 12/15/05, I want 12/31/05,
>
> For 10/15/1995, I want 10/31/1995, etc
>
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Dec 20 03:16:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:40 EST