Questions:
Should all queries simply restrict results by fiscal year?
To ensure that your query can show data from multiple fiscal years, make sure you have included table joins on all financial fields required.
Fields to Include in Queries that use Fiscal Year
| Table | Field | Notes |
|---|---|---|
Restricting Your Query Results by Fiscal Year
There are 2 ways you can restrict your query results by fiscal year: including start and end dates that correspond to a given fiscal year, or using a fiscal year field.
For instance, you can write a WHERE statement for the start and end dates, such as
WHERE ((SELECT start_date FROM parameters) ='' OR (invoice_payment_date::date >= (SELECT start_date FROM parameters)::DATE)) AND ((SELECT end_date FROM parameters) ='' OR (invoice_payment_date::date < (SELECT end_date FROM parameters)::DATE))
then add this parameter filter at the top of your query. Note that the dates below correspond to the start and end of Fiscal Year 2023.
/* Enter the start date and end date in YYYY-MM-DD format */ '2022-07-01'AS start_date, '2023-06-30'AS end_date,
Alternatively, you can use a fiscal year field in your query and include a parameter at the top of the query that allows the person running it to restrict results by a given fiscal year.
For instance, you can write
Here is an example of a section of a report that includes all the fields required for fiscal year.
Checking results in the Finance App