Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

What format expression for "end date of period" in period reports?

34 views
Skip to first unread message

IanTwenty

unread,
Sep 9, 2024, 9:35:22 AM9/9/24
to Ledger
Hi,

When I query by period such as --period "monthly" what do I put in a format string to output each period's end date? "%D" gives me the start date. I see that the "csv" command outputs end dates when used with period expressions but I can't see anything in its format string that does this?

Thanks,

Ian.

John Wiegley

unread,
Sep 9, 2024, 5:54:13 PM9/9/24
to IanTwenty, Ledger
>>>>> "I" == IanTwenty <ian....@gmail.com> writes:

I> When I query by period such as --period "monthly" what do I put in a format
I> string to output each period's end date? "%D" gives me the start date. I
I> see that the "csv" command outputs end dates when used with period
I> expressions but I can't see anything in its format string that does this?

This appears to be done with specialized logic here:

https://github.com/ledger/ledger/blob/johnw%2Fhashes/src/filters.cc#L880

It didn’t occur to me to make this information available to you through the
format specification. That should be a very hard thing to add, though. We just
have to create a new %E or some such flag, and then change filters.cc to
substitute the end date where %E is used, which would then be part of the
default string for reporting subtotaled ranges.

So, it needs changes in three areas:

1. Add a new format specifier for end-of-range.

2. Create a new “subtotals format” in report.h that is used by default for
reporting subtotaled ranges.

3. Change filters.cc to report its results using this format from #2.

John

IanTwenty

unread,
Sep 10, 2024, 9:04:52 AM9/10/24
to Ledger
Thanks John, that makes sense. I might use the csv output for now and if I have time in future look at making those changes you suggest.

John Wiegley

unread,
Sep 10, 2024, 10:58:29 AM9/10/24
to IanTwenty, Ledger
>>>>> "I" == IanTwenty <ian....@gmail.com> writes:

I> It didn’t occur to me to make this information available to you through
I> the format specification. That should be a very hard thing to add, though.

I meant to say, it _shouldn’t_ be a hard thing to add. It should be very easy,
in fact.

John
Reply all
Reply to author
Forward
0 new messages