MySQL Forums
Forum List  »  Newbie

Date Range Select for two date columns
Posted by: Donovan Brooke
Date: September 12, 2018 03:31PM

MySQL v: 5.6.38
PHP v: 5.6.35

Hi. I have events in a table with Starts and Ends DateTime columns:
1-----2018-09-28 00:00:00--------------2018-09-29 00:00:00
2-----2018-09-29 00:00:00--------------2018-10-29 00:00:00

Notice above show 2 is a month long.

I want to return to the user all shows within a date range criteria they send.

So if they send 9/27 to 2/28, only #1 is returned.
If they send 9/29 to 9/30, both are returned.
If they send 9/30 to 10/01, only #2 is returned.
If they send 8/5 to 11/5, both are returned.

Lastly, sometimes 'Ends' can be null (legacy entry). In this case, not sure what to do.

The statement I'm currently working works for only some of needs above. I'm hoping to get an example Select statement.. thx.


Options: ReplyQuote

Written By
Date Range Select for two date columns
September 12, 2018 03:31PM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.