2010-09-15 is wednesday
SQL
select * FROM events WHERE (week(event_date) = WEEK('2010-09-15') AND DAYOFweek(event_date) = 7) OR (week(event_date) = (WEEK('2010-09-15') +1) AND DAYOFweek(event_date) = 1)
Result
2010-09-18
2010-09-19
----------------------------------------------------------------------------------------
2010-09-18 is saturday
SQL
select * FROM events WHERE (week(event_date) = WEEK('2010-09-18') AND DAYOFweek(event_date) = 7) OR (week(event_date) = (WEEK('2010-09-18') +1) AND DAYOFweek(event_date) = 1)
Result
2010-09-18
2010-09-19
----------------------------------------------------------------------------------------
get current date's weekend
SQL
select * FROM events WHERE (week(event_date) = WEEK(CURDATE()) AND DAYOFweek(event_date) = 7) OR (week(event_date) = (WEEK(CURDATE()) +1) AND DAYOFweek(event_date) = 1)
Result
2010-09-18
2010-09-19
----------------------------------------------------------------------------------------
reference
http://www.webmasterworld.com/forum88/4585.htm
沒有留言:
發佈留言