Avatar of Sherry
Sherry
Flag for United States of America asked on

Selecting data within selected quarters in SQL

I have a query that uses a year and the quarter as parameters.  I having trouble finding any meaningful help on line to do this.  I have a timestamp from the table that I want to use.  It's an end date.  If the end date is within the beginning and ending quarter selected or  is null or after the ending quarter then I want that person.  The persons start date needs to be before or during the selected quarters.  

They select a year, beginning quarter and ending quarter.

I'm going to be using this in an SSRS report.  I can attach the code if needed.
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Sherry

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Brian Crowe

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Sherry

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jim Horn

<Not to change the closing of the question, but some added info>
If you're going to go the calendar table route, here's another article with ready-made T-SQL on how to build your own table, and please click the 'Good Article' button if it helped you.

This article has separate columns for calendar_year and calendar_quarter.   I've seen a few places that will create a view that has the combined year-quarter as in int value (e.g. 201504, 201601, 201602, ...) and then a text value (4th Quarter 2015, 1st Quarter 2016, 2nd Quarter 2017, etc.)  Then in the combo box that is displayed to the user only display the text, but make the int the bound value that is passed to the data source.

Good luck.
Sherry

ASKER
Although we don't have my data in the data warehouse as yet, Brian solution is the best and that's the way to go when I get it there.  I found something that will work for now.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy