I have table temp
with structure on sqlfiddle:
id(int 11 primary key)
name(varchar 100)
name2(varchar 100)
date(datetime)
I would like get record on this week, example if now 21.11.2013 i would like all rows on 18.11.2013 to 24.11.2013(on week)
Now I see next algorithm:
- obtain weekday
- calculate how many days ago was Monday
- calculate the date Monday
- calculate future date Sunday
- make a request on date
Tell me please, is exist a shorter algorithm (preferably in the query MySQL)?
ADD Question is: Why this query select record on date 17.11.2013(Sunday) - 23.11.2013(Saturday)
and how get records on date 18.11.2013(Monday) - 24.11.2013(Sunday)
?
query:
select * from temp
where yearweek(`date`) = yearweek(curdate())
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…