I am tryin to find a way to create a field in my query that will do the following:
- Check to see when the benefit start date falls between the FeeStart and FeeEnd dates
- Calculate the number of months between the FeeStart and FeeEnd dates for each fee period (note: benefits are ongoing between the price increases)
For example:
Benefit Start Date is 01/08/2018 and is currently set to expire on 31/08/2020. The query should return the following:
38Months as 17 (Aug 2018-Dec 2019 Inclusive)
40Months as 03 (January 2020 - Now Inclusive - or until the next expected fee end date)
Here is where I am at so far....
tbl_fees
FeeStart [Date time field formatted as dd/mm/yyyy]
Def: The date the Fee came into effect.
FeeEnd [Date time field formatted as dd/mm/yyyy]
Def: The data the Fee ceased to be in effect to a vendor price increase.
Fee [Currency field]
Def: Fee due to vendor during this time period.
Expand|Select|Wrap|Line Numbers
- FeeStart FeeEnd Fee
- 01/01/2018 31/12/2019 $38.00
- 01/01/2020 31/12/2022 $40.00
Start_Date [Date time field formatted as dd/mm/yyyy]
Def: The date our client was issued the benefit and is payable to the vendor.
End_Date [Date time field formatted as dd/mm/yyyy]
Def: The date our client benefit was cancelled and is no longer payable to the vendor.
At this time the two tables are not linked, and tbl_fees is used as a refence only; since we were not aware there would be price increases at the time the program was initiated and the database built.
qry_Reconciliation
Contains only those fields from tbl_data plus additional calculations as shown below
Expand|Select|Wrap|Line Numbers
- 38Months: IIf([Start_Date] Between #01/01/2018# And #01/01/2020#,(DateDiff("m",[Start_Date],#31/12/2019#)+1),0)
Expand|Select|Wrap|Line Numbers
- 38TOTAL: 38*[38Months]
Expand|Select|Wrap|Line Numbers
- 40Months: IIf([Start_Date] Between #01/01/2020# And #01/01/2023#,(DateDiff("m",[Start_Date],#31/12/2022#)+1),0)
Expand|Select|Wrap|Line Numbers
- Start_Date End_Date 38Months 38TOTAL 40Months
- 01/08/2018 31/07/2020 17 $646.00 0
- 01/09/2018 22/05/2019 16 $608.00 0
- 10/10/2018 31/10/2018 15 $570.00 0
- 05/11/2018 31/10/2020 14 $532.00 0
- 07/12/2018 30/11/2020 13 $494.00 0
- 04/01/2019 30/09/2019 12 $456.00 0
- 05/02/2019 31/01/2020 11 $418.00 0
- 26/03/2019 03/10/2019 10 $380.00 0
- 26/04/2019 31/03/2020 9 $342.00 0
- 14/05/2019 04/06/2019 8 $304.00 0
- 07/06/2019 18/11/2019 7 $266.00 0
- 15/08/2019 13/09/2019 5 $190.00 0
- 13/09/2019 01/11/2019 4 $152.00 0
- 03/10/2019 31/10/2020 3 $114.00 0
- 08/11/2019 22/11/2019 2 $76.00 0
- 07/01/2020 31/12/2020 0 $0.00 36
- 11/02/2020 30/04/2020 0 $0.00 35
- 05/03/2020 29/02/2020 0 $0.00 34
- 05/03/2020 31/08/2020 0 $0.00 34