-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
[CEP] date_add function for case search #31325
Comments
Is the logic of the
|
The actual logic would be done in python and make use of standard tools. For intervals that are fixed e.g. For intervals that are not fixed,
This would be the same date in the previous year or the closest valid date:
This would be the same date in the previous month (or the closet valid date):
|
|
yes, thanks. Updated comment. |
Sounds good. Does it make sense for the |
If we are referencing Elaboration: the singular names have different meanings for |
I don't think it makes sense for the docs to reference the python documentation. These functions will mostly be used by app builders or CommCare users using reports. Linking to the python docs would likely only add confusion, particularly as we are only offering some of the functionality that is available in python.
I don't have preference, we could accept both. In relativedelta singular names replace that field in the date with the given argument. If we exposed that functionality in the query DSL it would be as a separate function so I don't think there's any danger of accepting both. This is how SQL intervals work as well |
I'd prefer to only accept one form (plural) given the very important distinction in Edit: It's also nice to be strict with syntax so there are no ambiguities in the future. If you pass a non-plural value it should raise an error. Then if we ever want to support different meanings (like Otherwise 👍 on this CEP. |
I like this idea a lot. One thing I would also consider (separately) is that a lot of real-world use cases are around calendar date ranges, like "last month" or " this week (Monday-today)". That is, users might want the sliding scale, but relative to the start of the current period, not necessarily the day the report is run. This spec definitely gets us closer and I don't think it would step on the toes of any future fixed date range logic, just something to think about. |
Abstract
Support basic date arithmetic in case search query language. Specifically adding / subtracting static values from dates to enable calculating values like '1 month ago'.
Motivation
The Case Search Query language is used in Case List Explorer and in Applications via Case Search expressions.
In Case List Explorer it would be useful to be able to generate date ranges dynamically so that you could have saved reports which report on data in sliding date ranges. e.g. monthly report of cases closed in that month.
In Applications it is possible to do some date calculations by using the application xpath engine however these need to be done at the integer level (days since epoch) and so it is impossible to reliably compute month based intervals.
Specification
This CEP proposes a new Case Search query function to support adding and subtracting intervals from dates.
The function accepts 3 arguments:
Impact on users
Allow users to create queries with dynamic dates.
Impact on hosting
NA
Backwards compatibility
Since this is a new function there are no comparability issues
Release Timeline
NA
Open questions and issues
None at this time
The text was updated successfully, but these errors were encountered: