Hello, I recently came across a limitation in hledger while trying to build a more advanced expr: query involving dates.
For reference, Ledger supports date expressions in value expressions, including comparisons such as date < [tomorrow] and date >= [tomorrow]: Ledger CLI — Date Expressions
I'd like expr: queries to support date predicates as part of more advanced boolean expressions.
For example:
hledger is -p "2023 to 2028" --forecast='tomorrow..2028' -Y -3 -S \
expr:'(date:<tomorrow AND NOT tag:future) OR (date:>=tomorrow AND tag:future)'
The intended result is:
- Before tomorrow: include transactions not tagged
future.
- Tomorrow onward: include only transactions tagged
future.
I understand this particular forecasting example can be worked around by adjusting the periodic/budget entries and controlling the forecast period. However, I still think being able to apply different query conditions to different date ranges in a single expression would be useful more generally.
Ideally, date predicates such as these could be combined normally with AND, OR, NOT, and parentheses:
date:<today
date:<=today
date:>=tomorrow
date:>2027-01-01
Related: #2177 and #2178 cover the date/OR behavior that led to the current restriction, while #2095 discusses making expr: queries more expressive in general.
Thank you for all the work on hledger.
Hello, I recently came across a limitation in hledger while trying to build a more advanced
expr:query involving dates.For reference, Ledger supports date expressions in value expressions, including comparisons such as
date < [tomorrow]anddate >= [tomorrow]: Ledger CLI — Date ExpressionsI'd like
expr:queries to support date predicates as part of more advanced boolean expressions.For example:
The intended result is:
future.future.I understand this particular forecasting example can be worked around by adjusting the periodic/budget entries and controlling the forecast period. However, I still think being able to apply different query conditions to different date ranges in a single expression would be useful more generally.
Ideally, date predicates such as these could be combined normally with
AND,OR,NOT, and parentheses:Related: #2177 and #2178 cover the date/OR behavior that led to the current restriction, while #2095 discusses making
expr:queries more expressive in general.Thank you for all the work on hledger.