Page 1 of 1

query problem with data

Posted: Fri Oct 10, 2003 3:42 am
by Lod
I have a problem about a query.

I have a table with 4 column.
1) id (INT)
2) Special_Date (VARCHAR)
3) date_start (DATE)
4) date_finish (DATE)

In a page i use the function date() to have the date of today in a varible like this:

$today = date("Y-m-d");

I need to have a query that select the records from my table where the date of today is included between date_start and date_finish..

anyone can help me?

Posted: Fri Oct 10, 2003 5:10 am
by twigletmac
Maybe something like:

Code: Select all

SELECT field1, field2, field3 FROM table WHERE NOW() BETWEEN date_start AND date_end
Mac

Posted: Fri Oct 10, 2003 5:20 am
by mathewvp
If you want to select all data between two dates,you can use

Select * from table where thedate>='start_date' and thedate<='end_date';

Replace all the variables with correct names
NOW() gives current date with time.
if you want todays date use CURDATE() in mysql

Select * from table where CURDATE()>='start_date' and CURDATE()<='enddate';

Posted: Fri Oct 10, 2003 8:10 am
by Lod
tnx a lot people...you are my salvation