There is a table that lists each of four annual quarters and their start/end days and months.
Given this table and a start year of, say, 2017, how can I get a list of quarters in (end) date and name format, such as Q3 2017, '06/30/2017'?
I tried this but only get the current quarter:
select q.QID, q.QuarterName, q.StartMonth, q.StartDay, q.EndMonth, q.EndDay,
datefromparts(datepart (yy, '1/1/2017'), q.StartMonth, q.StartDay) StartQuarter,
datefromparts(datepart (yy, '6/28/2018'), q.EndMonth, q.EndDay) EndQuarter
from Quarters q
where datefromparts(datepart (yy, '6/28/2018'), q.EndMonth, q.EndDay) < '06/30/2018';
The "Quarters" table looks like:
QID QuarterName StartMonth StartDay EndMonth EndDay
1 First Quarter 10 1 12 31
2 Second Quarter 1 1 3 31
3 Third Quarter 4 1 6 30
4 Fourth Quarter 7 1 9 30
Not sure if this is relevant or not but it is used in .Net/C# environment.