Skip to content
Back to formatted view

Raw Message

Message-ID: <87v9c8fo2o.fsf@gmail.com>
Date: 2021-01-07T21:13:03Z
From: Jeremie Juste
Subject: seq.Date when date is the last date of the month
In-Reply-To: <24567.26670.290005.444615@rob.eddelbuettel.com> (Dirk Eddelbuettel's message of "Thu, 7 Jan 2021 13:59:42 -0600")

Hello Dirk,

Many thanks for the feedback. I did came across your SO answer but
didn't know the RcppBDT package, thanks for pointing that out.

Best regards,
Jeremie

On Thursday,  7 Jan 2021 at 13:59, Dirk Eddelbuettel wrote:
> Jeremie,
>
> As months have irregular number of dates, one needs to use a function that
> accounts for that (date libraries and packages have that, one of the earliest
> for R was my RcppBDT package using Boost Date_Time), or be otherwise clever.
>
> Here is a one-liner using the latter approach:
>
>    seq(as.Date("2010-02-01"), length=24, by="1 month") - 1
>
> See this old StackOverflow answer where I used this before:
>
>    https://stackoverflow.com/questions/8333838/generate-a-sequence-of-the-last-day-of-the-month-over-two-years
>
> Dirk

-- 
Jeremie Juste