troubleshooting Question

Running a Query Between Dates

Avatar of tonyhhisc
tonyhhisc asked on
DatabasesPHPMySQL Server
23 Comments1 Solution422 ViewsLast Modified:
Please help me figure out how to do this, how can a query be written for this? Or is there some php needed beforehand, I'm lost!


I have a Users table with their program start and end dates:


Name       Start           End
-----------------------------------------
Tony       Jan 1, 2012     Feb 1, 2012
Kamal      Jan 1, 2012     Mar 1, 2012
Shailesh   Feb 29, 2012    Oct 14, 2012    


I want to do a search for users that are in the program between the dates of.....(examples)...

Range: Jan 2, 2012 to March 5, 2012
Expected Result:  Tony, Kamal, Shailesh

Range: Feb 2, 2012 to Feb 20, 2012
Result: Kamal

Range: Jan 9, 2012 to Feb 28, 2012
Result: Tony, Kamal


Since the days between the start and end dates are not stored in the database, how in the ***** do I run a query on them?
I guess I could just store all the days between the dates in the database, but that seems like a bad solution.

Thanks for your help!

Tony
ASKER CERTIFIED SOLUTION
Scott Madeira

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros