返回财政年度的第一天(4月1日)T-SQL

问题描述:

财政年度的第一天是4月1日.

First Day of financial year is April 1st.

T-SQL查询将在4月1日返回 getdate()

T-SQL Query to return April 1st for the getdate()

财政年度:4月1日至3月31日

Financial Year: April 1st to March 31st

尝试一下:

select DATEFROMPARTS(Yr, 4, 1) [start], DATEFROMPARTS(Yr + 1, 3, 31) [end] from 
(select case when DATEPART(month, getdate()) < 4 then DATEPART(year, getdate()) - 1 else DATEPART(year, getdate()) end Yr) a