I want to display all the dates that are included in a particular quarter ex: if my input is Q1 and 2021, my output should be
01/01/2021
01/02/2021
--------
---------
-------
03/31/2021
I want to display all the dates that are included in a particular quarter ex: if my input is Q1 and 2021, my output should be
01/01/2021
01/02/2021
--------
---------
-------
03/31/2021
I guess you can start from something like this^
DECLARE @InFirstQuarterDate DATE='20210101';
DECLARE @InLAstQuarterDate DATE=DATEADD(DAY,-1, DATEADD(MONTH,3*DATEPART(QUARTER,@InFirstQuarterDate), DATENAME(YEAR,@InFirstQuarterDate)));
--SELECT @InFirstQuarterDate,@InLAstQuarterDate
WITH CTE AS
(
SELECT @InFirstQuarterDate AS DD
UNION ALL
SELECT DATEADD(DAY,1,C.DD)AS DD
FROM CTE AS C
WHERE DATEADD(DAY,1,C.DD)<=@InLAstQuarterDate
)
SELECT C.DD
FROM CTE AS C