LoginSignup
4
1

More than 3 years have passed since last update.

【Laravel】24時間以内に作成されたユーザーの数を集計する【指定範囲のデータ取得】

Posted at

1日

use DB;

DB::table('users')
  ->orderBy('created_at','desc')
  ->whereRaw('created_at > NOW() - INTERVAL 1 DAY')
  ->count()

30分

  ->whereRaw('created_at > NOW() - INTERVAL 30 MIN')

リファレンス

この記事が作成されている時点では、以下のリファレンスが用意されていたのですが、バージョンアップで参照できなくなるとおもうので、適宜環境にあったリファレンスを参照してください。

image.png

筆者のサーバー環境はMySQL 5.5だったのだけど、実行環境依存だとおもうので、MINとかが使えないバージョンなどもあったりするのだろうか。。。 :thinking:

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1