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?
query problem with data
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Maybe something like:
Mac
Code: Select all
SELECT field1, field2, field3 FROM table WHERE NOW() BETWEEN date_start AND date_endIf 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';
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';