why for 11/2/2021, you have 07/01/2020 till 11/30/2021. Wouldn't the previous July be 7/1/2021?
declare @startdate date, @enddate date, @today date = GetDate() --'2/5/2022'--
,@adjustment int
set @adjustment = case when month(@today) < 7
then 1
when month(@today) > 7
then 0
else
0
end
set @startdate = cast('07/01/' + cast(year(@today) - @adjustment as char(4)) as date)
set @enddate = EOMonth(@today)
If you need a date data type: datefromparts(year(getdate()) - iif(month(getdate()) < 7, 1, 0), 7, 1)
If you need a datetime data type: datetimefromparts(year(getdate()) - iif(month(getdate()) < 7, 1, 0), 7, 1, 0, 0, 0, 0)