This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

AcmeGareth
AcmeGareth

Hello all,

I would like to know if it is possible to run a sql query that counts all records for past 30 days like this:

"$this->orders = Db::table('orders')->where('client_name', $user->name)->count(last 30 days);"

ndcisiv
ndcisiv

$this->orders = DB::table('orders')->where('client_name',$user->name)->where('order_date','>=',strtotime('-30 days'))->count();

AcmeGareth
AcmeGareth

ndcisiv said:

$this->orders = DB::table('orders')->where('client_name',$user->name)->where('order_date','>=',strtotime('-30 days'))->count();

Worked like a charm, thanks so much!

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.