Page 1 of 1

SQL Date

Posted: Thu Jan 29, 2004 11:37 pm
by glennalmeda
What is the SQL Statement for searching a record in between two dates? Thank You!

Posted: Fri Jan 30, 2004 12:24 am
by jaxn
I could be wrong on this, but I think the only SQL99 way to do it is with BETWEEN.

i.e.

Code: Select all

SELECT date FROM table WHERE date BETWEEN '$start_date' AND '$end_date'
$start_date and $end_date need to be in the proper format for your date column (YYYYMMDD for date type columns).

Most databases have special functions for working with dates. Here is a list of the ones for MySQL.
http://www.mysql.com/doc/en/Date_and_ti ... tions.html

-Jackson