Faqts : Business : Programming : Shopping For You : PHP : Function Libraries : Date and Time

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

61 of 67 people (91%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

With a mysql query how do you find all the information between two times (i.e. from date1 to date2)

Jul 16th, 2002 16:58
Dan Halbert, Kris Tidblom,


Suppose your table has a column called "date", and you have $begin_date 
and $end_date with values like '2002-08-01' and '2002-09-30'. Then do 
something like:


SELECT * FROM my_table WHERE date BETWEEN '$begin_date' AND'$end_date';

BETWEEN is inclusive - it includes both the beginning and end. This
is clearer but the same as:

... WHERE '$begin_date' <= date AND '$end_date' <= date;