Hi there everyone,

Im looking for a solution regarding a project im involved with which needs to run a script that search's between dates.

Im running a table like this example:

ID - date_begin - date_end - price
1 01-01-2009 31-01-2009 1€
2 01-02-2009 14-02-2009 2€
3 15-02-2009 27-03-2009 3€
....

And i have a search box in PHP which allows me to search a date like 15-01-2009.

But I need to search 15-01-2009 and return this date interval (1 01-01-2009 31-01-2009 1€).

Is there any query to make this work?

Thanks in advance

Recommended Answers

All 2 Replies

Hi there everyone,

Im looking for a solution regarding a project im involved with which needs to run a script that search's between dates.

Im running a table like this example:

ID - date_begin - date_end - price
1 01-01-2009 31-01-2009 1€
2 01-02-2009 14-02-2009 2€
3 15-02-2009 27-03-2009 3€
....

And i have a search box in PHP which allows me to search a date like 15-01-2009.

But I need to search 15-01-2009 and return this date interval (1 01-01-2009 31-01-2009 1€).

Is there any query to make this work?

Thanks in advance

For future reference:
SELECT *
FROM fsdhfs
WHERE date_begin <= "2009-01-15"
AND date_end >= "2009-01-15"
LIMIT 0 , 30

Or This code works well with lots of conditions to meet

$sql = "SELECT * FROM artists_details LEFT JOIN attendance ON attendance.record_id AND attendance.visit_date >= '".$from_date."' AND attendance.visit_date <= '".$to_date."' WHERE artists_details.youth='youth' AND attendance.artist_id=artists_details.artist_id AND artists_details.outreach='outreach'";
//echo $sql;
$result4=mysql_query($sql);
$num_rows_y = mysql_num_rows($result4);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.