Number of VanHalen concerts in past_X years prior to a point in time

Hello!

I'm working in SQL Server 2012 and need to create counts of events that occurred prior to a specific point in time.

Let me use an analogy to represent what I'm trying to do because what I'm really doing is so incredibly top secret I would have to violate my own moral underpinnings were I to reveal it here (i.e., I'd tell ya but I'd hafta kill ya). :P

Let's say I have a table of people and the date that each person attended a VanHalen concert in the past 50 years.  

I want to count the number of prior VanHalen concerts each person had attended prior to the concert date under examination.  

So - let's say a guy named Jim attended a VanHalen concert on 3/27/1986 (to see what this whole Hagar thing was all about).

Prior to that he had been to shows in:
Chicago 3/3/1978,
Milwaukee 3/9/1978,
San Diego 12/3/1978,
Seattle 4/5/1980 (A leap year), and
Omaha 8/8/1982 (the Hide Your Sheep tour - cuz that's just funny!)

So Jim attended a total of 5 VH concerts prior to the show on 3/27/1986 (including one during a leap year because - well leap years are just a PITA).  

Given the above information - what would be the best way to determine how many concerts each person had attended prior to each concert date while accounting for leap years?

I also want to know how many concerts he attended in the past 1,2,3,4, etc. years.

TIA and well, Rock on!
LVL 1
ttist25Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
nothing wrong with leap years.
not knowing how your data tables are arranged makes things difficult. A Sql diagram would be nice.
pseudo code
#date = "01/01/1990 00:00:00"
select * from concerts where concetdate < #DATE# where artist = 'Van Halen" AND user = "Jim'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ttist25Author Commented:
THanks David.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.