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 betwe开发者_Python百科en the start_date and end_date of a specified week.
SELECT week
FROM table_name
WHERE CURRENT_DATE() BETWEEN start_date AND end_date
CURRENT_DATE() is synonyms for CURDATE().
SELECT week FROM TABLE_NAME WHERE CURDATE() BETWEEN start_date AND end_date;
Pretty simple:
SELECT week FROM my_table WHERE CURRENT_DATE > start_date AND CURRENT_DATE <= end_date
精彩评论