Page 1 of 1

Get current week

Posted: Thu Jan 17, 2008 8:44 pm
by GeXus
I'm trying to do a query to get items that fall within the current week... This is the query i'm using

Code: Select all

 
 
SELECT a.id, a.name, a.description, a.category_id, a.language_id, a.guid from quizzes a
inner join quiz_ratings b on a.id = b.quiz_id
where a.active = '1' and YEARWEEK(b.created_dt) = YEARWEEK(CURRENT_DATE - INTERVAL 7 DAY)
 
 
This doesn't work though, it returns zero results, but created_dt has date stamps for today..

Any ideas? Thanks!

Re: Get current week

Posted: Thu Jan 17, 2008 11:38 pm
by Kieran Huggins
try:

Code: Select all

SELECT a.id, a.name, a.description, a.category_id, a.language_id, a.guid 
FROM quizzes AS a
INNER JOIN quiz_ratings AS b ON a.id = b.quiz_id
WHERE a.active = '1' 
AND YEARWEEK(DATE_SUB(CURDATE(),INTERVAL 15 DAY)) >= YEARWEEK(b.created_dt);