Message-ID: <Pine.LNX.4.58.0510121147190.24069@maplepark.com>
Date: 2005-10-12T16:50:22Z
From: David Forrest
Subject: adding 1 month to a date
In-Reply-To: <2a9c000c0510120904u638019a5lfd84f3741df53631@mail.gmail.com>
On Wed, 12 Oct 2005, Jim Porzak wrote:
> OTOH,
>
> > seq(as.Date("2004-01-31"), by = "month", length = 14)
> [1] "2004-01-31" "2004-03-02" "2004-03-31" "2004-05-01" "2004-05-31"
> [6] "2004-07-01" "2004-07-31" "2004-08-31" "2004-10-01" "2004-10-31"
> [11] "2004-12-01" "2004-12-31" "2005-01-31" "2005-03-03"
>
> I would prefer to see dates forced to be within each month, not
> "leaking" into next month.
>
> IOW:
> [1] "2004-01-31" "2004-02-29" "2004-03-31" "2004-04-30" "2004-05-31", etc
It depends how you intend "1 month after 2004-01-31". Is the the same
number of days before the beginning of the next month or after the end of
the stated month?
seq(as.Date("2004-02-01"), by = "month", length = 14)-1
[1] "2004-01-31" "2004-02-29" "2004-03-31" "2004-04-30" "2004-05-31"
Dave
--
Dr. David Forrest
drf at vims.edu (804)684-7900w
drf5n at maplepark.com (804)642-0662h
http://maplepark.com/~drf5n/