开发者

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 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜