Re: Search Between Dates
| From: | Russ Michell | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Search Between Dates | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13367@lists.php.net to get a copy of this message | ||
Try something like:
$sql = "SELECT * FROM <table_name> WHERE NOW()>='$startdate' AND
NOW()<='$enddate' ORDER BY
'startdate' DESC";
This query will return results from teh database whose startdate is between a date:$startdate in
the past
(compared to this instant) and a date:$enddate in the future.
Check out: http://www.mysql.com/doc/D/a/Date_and_time_functions.html
for more date and time stuff.
Cheers
Russ
On Tue, 16 Oct 2001 10:43:16 -0400 Kyle Mathews <kyle@thedip.net> wrote:
> Hello:
>
> I'm looking to create a search function that can take a starting and ending
> date from a user, and compare that with other start and end dates in a
> database. I would like it to check if any of the days within the users start
> and end dates fall within any days in the start and end dates within the
> database.
>
> I'm not sure if this can be accomplished on the SQL query, or if it needs to
> later check for this in an IF statement.
>
> Any help would be appreciated.
>
> Thanks,
> Kyle
> kyle@thedip.net
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
#-------------------------------------------------------#
"Believe nothing - consider everything"
Russ Michell
Anglia Polytechnic University Webteam
Room 1C 'The Eastings' East Road, Cambridge
e: r.j.michell@apu.ac.uk
w: www.apu.ac.uk/webteam
www.theruss.com
#-------------------------------------------------------#