给定日期属于哪个财政年度季度?

Which Fiscal Year Quarter the given date falls into?

示例: 我有一个日期 02/11/2019(这是 2019 财年的第 4 季度) 我想使用 SQL 找出它属于财政年度的哪个季度 我们的财政年度从 7 月 1 日开始

假设 2021 财年从 2020 年 7 月 1 日开始,那么只需将日期加上 6 个月并使用常规日期函数即可:

select year(dateadd(month, 6, datecol )) as fiscal_year,
       quarter(dateadd(month, 6, datecol)) as fiscal_quarter

如果 2020 财年从 2020 年 7 月 1 日开始,则减去 6 个月而不是增加 6 个月。