-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "quarter" option to floor_date and ceiling_date #239
Comments
This is my implementation of adding "quarter" to floor_date:
The formula for month is kind of confusing, but is based on the map from month to quarter number (e.g. February is month 2, so ceiling(2/3) = 1, Quarter 1). This the implementation for
Here are some example outputs:
|
I plugged in the "quarter" option into
|
Even more generally, why not wrap |
Because these generics accept only one argument and operations on dates are quite meaningless without the |
There are existing methods |
Ahh ... you are right. I looked at To be honest I don't like |
This is incomplete. You need to set smaller units to 0 as well.
Maybe a bit simpler would be
I don't think so. Implementation for quarter must be very similar to that of the month. I think the rationale of that code is that If the date is exactly at the beginning of the month or quarter you want to keep it as it is. BTW. Could you please propose a PR next time? It would be easier to comment on the code. Thanks. |
@jonboiser fixed this in #303. I forgot to close it back then. |
Add "quarter" option to floor_date and ceiling_date functions, thus any date is transformed to be the first or last day of the quarter.
This is particularly useful if on wants to work with quarterly aggregated data (the quarter function does not output a date object and thus, is limited in its usefulness if one wants to calculate sequences etc. based on the quarter information).
The text was updated successfully, but these errors were encountered: