Reputation: 4816
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
Reputation: 64137
SELECT week FROM TABLE_NAME WHERE CURDATE() BETWEEN start_date AND end_date;
Upvotes: 1
Reputation: 196
SELECT week
FROM table_name
WHERE CURRENT_DATE() BETWEEN start_date AND end_date
CURRENT_DATE() is synonyms for CURDATE().
Upvotes: 2
Reputation: 2471
Pretty simple:
SELECT week FROM my_table WHERE CURRENT_DATE > start_date AND CURRENT_DATE <= end_date
Upvotes: 0