;doc: clarify period expressions, report intervals

This commit is contained in:
Simon Michael 2021-08-17 08:54:34 -10:00
parent 5c18fb289f
commit 1874a971dc

View File

@ -491,8 +491,8 @@ All of these accept the [smart date](#smart-dates) syntax.
Some notes: Some notes:
- As in Ledger, end dates are exclusive, so you need to write the date *after* - End dates are exclusive, as in Ledger, so you should write the date *after*
the last day you want to include. the last day you want to see in the report.
- As noted in [reporting options](#general-options): - As noted in [reporting options](#general-options):
among start/end dates specified with *options*, the last (i.e. right-most) among start/end dates specified with *options*, the last (i.e. right-most)
option takes precedence. option takes precedence.
@ -526,11 +526,11 @@ column.
The following "standard" report intervals can be enabled by using The following "standard" report intervals can be enabled by using
their corresponding flag: their corresponding flag:
`-D/--daily`, - `-D/--daily`
`-W/--weekly`, - `-W/--weekly`
`-M/--monthly`, - `-M/--monthly`
`-Q/--quarterly`, - `-Q/--quarterly`
`-Y/--yearly`. - `-Y/--yearly`
These standard intervals always start on natural interval boundaries: These standard intervals always start on natural interval boundaries:
eg `--weekly` starts on mondays, `--monthly` starts on the first of eg `--weekly` starts on mondays, `--monthly` starts on the first of
@ -551,6 +551,14 @@ starts earlier than your requested start date, or ends later than your
requested end date). This is done to ensure "full" first and last requested end date). This is done to ensure "full" first and last
subperiods, so that all subperiods' numbers are comparable. subperiods, so that all subperiods' numbers are comparable.
To summarise:
- In multiperiod reports, all subperiods are forced to be the same length, to simplify reporting.
- Reports with the standard `--weekly`/`--monthly`/`--quarterly`/`--yearly` intervals
are required to start on the first day of a week/month/quarter/year.
We'd like more flexibility here but it isn't supported yet.
- `--period` (below) can specify more complex intervals, starting on any date.
## Period expressions ## Period expressions
The `-p/--period` option accepts period expressions, a shorthand way The `-p/--period` option accepts period expressions, a shorthand way
@ -607,11 +615,14 @@ Or you can specify a single quarter like so:
| `-p "2009Q1"` | first quarter of 2009, equivalent to “2009/1/1 to 2009/4/1” | | `-p "2009Q1"` | first quarter of 2009, equivalent to “2009/1/1 to 2009/4/1” |
| `-p "q4"` | fourth quarter of the current year | | `-p "q4"` | fourth quarter of the current year |
The argument of `-p` can also begin with, or be, a [report interval](#report-intervals) expression. ### Period expressions with a report interval
The basic report intervals are `daily`, `weekly`, `monthly`, `quarterly`, or `yearly`,
which have the same effect as the `-D`,`-W`,`-M`,`-Q`, or `-Y` flags. `-p/--period`'s argument can also begin with, or entirely consist of,
Between report interval and start/end dates (if any), the word `in` is optional. a [report interval](#report-intervals).
Examples: This should be separated from the start/end dates (if any) by a space, or the word `in`.
The basic intervals (which can also be written as command line flags)
are `daily`, `weekly`, `monthly`, `quarterly`, and `yearly`.
Some examples:
| | | |
|-----------------------------------------| |-----------------------------------------|
@ -619,10 +630,9 @@ Examples:
| `-p "monthly in 2008"` | | `-p "monthly in 2008"` |
| `-p "quarterly"` | | `-p "quarterly"` |
Note that `weekly`, `monthly`, `quarterly` and `yearly` intervals will As mentioned above, the `weekly`, `monthly`, `quarterly` and `yearly` intervals
always start on the first day on week, month, quarter or year - require a report start date that is the first day of a week, month, quarter or year
accordingly, and will end on the last day of same period, even if - and report start/end dates will be expanded if needed to span a whole number of these intervals.
associated period expression specifies different explicit start and end date.
For example: For example:
@ -633,16 +643,18 @@ For example:
| `-p "quarterly from 2009-05-05 to 2009-06-01"` | starts on 2009/04/01, ends on 2009/06/30, which are first and last days of Q2 2009 | | `-p "quarterly from 2009-05-05 to 2009-06-01"` | starts on 2009/04/01, ends on 2009/06/30, which are first and last days of Q2 2009 |
| `-p "yearly from 2009-12-29"` | starts on 2009/01/01, first day of 2009 | | `-p "yearly from 2009-12-29"` | starts on 2009/01/01, first day of 2009 |
The following more complex report intervals are also supported: ### More complex report intervals
`biweekly`,
`fortnightly`,
`bimonthly`,
`every day|week|month|quarter|year`,
`every N days|weeks|months|quarters|years`.
Some more complex kinds of interval are also supported in period expressions:
All of these will start on the first day of the requested period and end on the last one, as described above. - `biweekly`
- `fortnightly`
- `bimonthly`
- `every day|week|month|quarter|year`
- `every N days|weeks|months|quarters|years`
These too will cause report start/end dates to be expanded, if needed,
to span a whole number of intervals.
Examples: Examples:
| | | | | |
@ -651,15 +663,18 @@ Examples:
| `-p "every 2 weeks"` | starts on closest preceding Monday | | `-p "every 2 weeks"` | starts on closest preceding Monday |
| `-p "every 5 month from 2009/03"` | periods will have boundaries on 2009/03/01, 2009/08/01, ... | | `-p "every 5 month from 2009/03"` | periods will have boundaries on 2009/03/01, 2009/08/01, ... |
If you want intervals that start on arbitrary day of your choosing and span a week, month or year, you need to use any of the following: ### Intervals with custom start date
`every Nth day of week`, All intervals mentioned above are required to start on their natural calendar boundaries,
`every WEEKDAYNAME` (eg `mon|tue|wed|thu|fri|sat|sun`), but the following weekly, monthly and yearly intervals can start on any date:
`every Nth day [of month]`,
`every Nth WEEKDAYNAME [of month]`, - `every Nth day of week` (`th`, `nd`, `rd`, or `st` are all accepted after the number)
`every MM/DD [of year]`, - `every WEEKDAYNAME` (full or three-letter english weekday name, case insensitive)
`every Nth MMM [of year]`, - `every Nth day [of month]`
`every MMM Nth [of year]`. - `every Nth WEEKDAYNAME [of month]`
- `every MM/DD [of year]` (month number and day of month number)
- `every Nth MONTHNAME [of year]` (full or three-letter english month name, case insensitive)
- `every MONTHNAME Nth [of year]`
Examples: Examples:
@ -669,17 +684,21 @@ Examples:
| `-p "every Tue"` | same | | `-p "every Tue"` | same |
| `-p "every 15th day"` | period boundaries will be on 15th of each month | | `-p "every 15th day"` | period boundaries will be on 15th of each month |
| `-p "every 2nd Monday"` | period boundaries will be on second Monday of each month | | `-p "every 2nd Monday"` | period boundaries will be on second Monday of each month |
| `-p "every 11/05"` | yearly periods with boundaries on 5th of Nov | | `-p "every 11/05"` | yearly periods with boundaries on 5th of November |
| `-p "every 5th Nov"` | same | | `-p "every 5th November"` | same |
| `-p "every Nov 5th"` | same | | `-p "every Nov 5th"` | same |
Show historical balances at end of 15th each month (N is exclusive end date): Show historical balances at end of the 15th day of each month (N is an end date, exclusive as always):
`hledger balance -H -p "every 16th day"` ```shell
$ hledger balance -H -p "every 16th day"
```
Group postings from start of wednesday to end of next tuesday (N is start date and exclusive end date): Group postings from the start of wednesday to end of the following tuesday (N is both (inclusive) start date and (exclusive) end date):
`hledger register checking -p "every 3rd day of week"` ```shell
$ hledger register checking -p "every 3rd day of week"
```
# DEPTH # DEPTH