SQL/VBA: How to group by a fiscal year starting from a day other than 1st day of month

后端 未结 2 382
清酒与你
清酒与你 2021-01-29 14:19

I’m trying (using MS Access) to group some data by a fiscal year, which can be different to the calendar year.

If every fiscal year always started on the 1st of a given

2条回答
  •  一生所求
    2021-01-29 15:08

    If you have month + day to take into consideration, then obviously you will need the corresponding 2 fields in your table (NOT NULL DEFAULT 1).

    Once this is added, the following will calculate the year: year(orderDate) - IIF(dateserial(year(orderDate), startFYofaCompany_month, startFYofaCompany_day) > orderDate, 1, 0)

    Add this to the 2 places you have prepared in your query.

提交回复
热议问题