Answer the question
In order to leave comments, you need to log in
How to select users created in the previous week in laravel?
For the current week I choose
$count = Users::whereDate('created_at', '>=', date('Y-m-d H:i:s', strtotime('-7 days')))->count();
$count = Users::whereDate([
['created_at', '<', date('Y-m-d H:i:s', strtotime('-7 days'))],
['created_at', '>=', date('Y-m-d H:i:s', strtotime('-14 days'))],
])->count();
Answer the question
In order to leave comments, you need to log in
$count = Users::whereDate('created_at', '<', date('Ymd H:i:s', strtotime('-7 days')))->whereDate('created_at', '>=', date('Ymd H:i:s', strtotime('-14 days')))->count();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question