Fawad Ghafoor
Fawad Ghafoor

Reputation: 6207

mysql between query in dates

$currentdate = date("Y-m-d");
$lastweekdate = date("Y-m-d", strtotime("-6 days")); 
$querytopscoreofweek  = 
"SELECT * FROM fb_user WHERE  last_date".
" BETWEEN $lastweekdate AND $currentdate ORDER BY oldscore DESC LIMIT 0,10";

i have field name last_date in this format $currentdate = date("Y-m-d"); i want to execute the above query i want it to return all the users of last week and mean between $lastweekdate and $currentdate and which has also old_score greater in descending order and only 10 users,BUT THE PROBLEM IS THAT IT IS NOT RETURNING ANY THING ANY HINT PLZ

Upvotes: 0

Views: 173

Answers (1)

Nicola Cossu
Nicola Cossu

Reputation: 56357

SELECT * 
FROM fb_user 
WHERE last_date BETWEEN curdate() AND curdate() - interval 6 day 
ORDER BY oldscore DESC LIMIT 10

Upvotes: 1

Related Questions