Go through range of dates

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
aquanutz
Forum Commoner
Posts: 28
Joined: Thu Sep 14, 2006 9:07 am

Go through range of dates

Post by aquanutz »

Hello,

I've got a few tables in MySQL that have ranges of dates (a starting date and an ending date) and in my calendar I want to be able to check the current date against those in the ranges to see if there are events... The only thing is that I can not seem to come up with a good way (or start a good way) to do this. Is there an easy way to see if a date is in a range of other dates?? Thanks for any help.

-thomas
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

Something like:

Code: Select all

SELECT * 
FROM table_name
WHERE $today_date BETWEEN start_date AND end_date
should do it, where $today_date comes from the PHP script.
aquanutz
Forum Commoner
Posts: 28
Joined: Thu Sep 14, 2006 9:07 am

Post by aquanutz »

You are a freakin' life saver! :D :D :D
Post Reply