Jeff Thomas
Jeff Thomas

Reputation: 4816

PHP mysql_query - Get row of current week with current date

I have a mysql table as follows:

week    start_date  end date
1   2011-04-25  2011-05-01
2   2011-05-02  2011-05-08
3   2011-05-09  2011-05-15

I would like to run a query to get the week number when the current date is between the start_date and end_date of a specified week.

Upvotes: 0

Views: 873

Answers (3)

Mike Lewis
Mike Lewis

Reputation: 64137

SELECT week FROM TABLE_NAME WHERE CURDATE() BETWEEN start_date AND end_date;

Upvotes: 1

Mario
Mario

Reputation: 196

SELECT week
FROM table_name
WHERE CURRENT_DATE() BETWEEN start_date AND end_date 

CURRENT_DATE() is synonyms for CURDATE().

Upvotes: 2

colinmarc
colinmarc

Reputation: 2471

Pretty simple:

SELECT week FROM my_table WHERE CURRENT_DATE > start_date AND CURRENT_DATE <= end_date

Upvotes: 0

Related Questions