回答編集履歴

2

誤解を招く表現を修正

2018/10/30 07:14

投稿

madoka9393
madoka9393

スコア992

test CHANGED
@@ -14,19 +14,19 @@
14
14
 
15
15
  //最新ログインが本日
16
16
 
17
- where DATE(current_sign_in_at)=DATE(NOW());
17
+ select * from users where DATE(current_sign_in_at)=DATE(NOW());
18
18
 
19
19
 
20
20
 
21
21
  //〃3日以内
22
22
 
23
- where DATE(current_sign_in_at) between DATE(NOW()) - interval 3 day and DATE(NOW());
23
+ select * from users where DATE(current_sign_in_at) between DATE(NOW()) - interval 3 day and DATE(NOW());
24
24
 
25
25
 
26
26
 
27
27
  //〃1週間以内
28
28
 
29
- where DATE(current_sign_in_at) between DATE(NOW()) - interval 7 day and DATE(NOW());
29
+ select * from users where DATE(current_sign_in_at) between DATE(NOW()) - interval 7 day and DATE(NOW());
30
30
 
31
31
  ```
32
32
 

1

追記

2018/10/30 07:14

投稿

madoka9393
madoka9393

スコア992

test CHANGED
@@ -1,4 +1,10 @@
1
1
  既に回答ついてますが多分こんな感じかと。
2
+
3
+
4
+
5
+ 追記
6
+
7
+ 日付が時分秒含むみたいなので時分秒抜いて(日付部分とだけで)チェックするように変更
2
8
 
3
9
 
4
10
 
@@ -8,23 +14,19 @@
8
14
 
9
15
  //最新ログインが本日
10
16
 
11
- where current_sign_in_at=DATE(NOW());
17
+ where DATE(current_sign_in_at)=DATE(NOW());
12
-
13
- //current_sign_in_at が時分秒まで含む場合
14
-
15
- where current_sign_in_at between DATE(NOW()) and DATE(NOW()) + interval 1 day;
16
18
 
17
19
 
18
20
 
19
21
  //〃3日以内
20
22
 
21
- where current_sign_in_at between DATE(NOW()) - interval 3 day and DATE(NOW());
23
+ where DATE(current_sign_in_at) between DATE(NOW()) - interval 3 day and DATE(NOW());
22
24
 
23
25
 
24
26
 
25
27
  //〃1週間以内
26
28
 
27
- where current_sign_in_at between DATE(NOW()) - interval 7 day and DATE(NOW());
29
+ where DATE(current_sign_in_at) between DATE(NOW()) - interval 7 day and DATE(NOW());
28
30
 
29
31
  ```
30
32