You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code below, the first call to the EOMONTH function returns NA when I expect February 28, 2019. The second call works correctly. Both calls work correctly in Excel which this function is trying to replicate.
I have version 1.0.4 of tidyquant and version 4.1.2 of R (Bird Hippie)
(update) In StackOverflow a thread indicated that one should adjust the start date to an earlier date. I propose a different logic based on the fact that the end of a month is one day before the first day of the next month. Here's some code.
if (rlang::is_missing(start_date))
start_date <- TODAY()
start_date <- lubridate::as_date(start_date)
y <- year(start_date) + floor(months / 12)
months <- months - floor(months / 12) * 12
m <- month(start_date) + months
if(m >= 11) y <- y + 1
m <- m + 1
if(m > 12) m <- m - 12
return(make_date(y, m, 1) - days(1))
}```
The text was updated successfully, but these errors were encountered:
In the code below, the first call to the EOMONTH function returns NA when I expect February 28, 2019. The second call works correctly. Both calls work correctly in Excel which this function is trying to replicate.
I have version 1.0.4 of tidyquant and version 4.1.2 of R (Bird Hippie)
(update) In StackOverflow a thread indicated that one should adjust the start date to an earlier date. I propose a different logic based on the fact that the end of a month is one day before the first day of the next month. Here's some code.
The text was updated successfully, but these errors were encountered: