views:

41

answers:

1

I want to select data between 1 week ago data until today data:

SELECT username, 
       email, 
       date 
FROM users 
WHERE date(date) BETWEEN (CURDATE() AND (CURDATE() - 7)) 
ORDER BY userid DESC 
LIMIT 10

Hope you guys can help me. It does not work!!!

This question has been answered by lexu

(can somebody close this question?)

+2  A: 
SELECT username
     , email
     , date 
FROM users 
WHERE date(date) BETWEEN DATE_SUB(CURDATE(), interval 1 week) 
                     AND CURDATE() 
ORDER BY userid DESC
  • BETWEEN demands that you give the lower boundary first.
  • use DATE_SUB with an interval of 1 week
lexu
works perfectly... Thank you very much!!
flashnewbie
your welcome .. have fun!
lexu