Get this week users

55 Views Asked by At

I have this code:

$sdf = mysql_query("SELECT * FROM users WHERE (DATE(date) = date_sub(date('2013-11-02 00:00:00'), INTERVAL 1 WEEK)) ORDER BY id DESC LIMIT 5");

And would like to get this week's users.. how many who have created an account this week. Now it add's one week from today to next monday. BUT. I want JUST this week, not 7 days forward. How can I do this?

1

There are 1 best solutions below

2
On BEST ANSWER

I think date_format is enough for what you need.

select *
from users
where DATE_FORMAT(your_date_column,"%u-%Y") = "44-2013"

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format