love
love

Reputation: 1391

mysql query problem

id   url                    start        end
1    http://yahoo.com      2010-10-17    2010-10-10
2    http://google.com     2010-10-15    2010-12-11
3    http://espan.com      2010-10-20    2011-01-20
4    http://espan.com      2010-10-01    2011-01-01

if Today is 2010-10-16..

how can I get results work in today.

2    http://google.com     2010-10-15    2010-12-11
4    http://espan.com      2010-10-01    2011-01-01

Upvotes: 0

Views: 56

Answers (3)

Salman Arshad
Salman Arshad

Reputation: 272006

Something like this?

SELECT *
FROM that_table
WHERE CURRENT_TIMESTAMP BETWEEN start AND end

Note that:

  1. in the above example, both dates are "inclusive"
  2. in the above example, CURRENT_TIMESTAMP includes the "time" part as well

Upvotes: 1

bassneck
bassneck

Reputation: 4043

SELECT * FROM your_table WHERE CURDATE() >= start AND CURDATE() <= end

Upvotes: 2

Tony
Tony

Reputation: 10327

SELECT id, url, start, end
FROM Your_Table
WHERE 2010-10-16 BETWEEN start AND end

Replace 2010-10-16 with CURRENT_TIMESTAMP or equivalent in MySQL

Upvotes: 2

Related Questions