44
33

More than 5 years have passed since last update.

MySQLでの日付型の加算と減算

Posted at

普通に update_at < 数字
の形式もいいけど、N日先や、Nヶ月先ってが調べられる

select count(*) from user where updated_at < DATE_SUB( now(), interval '31' DAY ) ;
例:現在から三ヶ月先
DATE_ADD(CURRENT_DATE(),INTERVAL 3 MONTH)

例:現在から一ヶ月前
DATE_SUB(CURRENT_DATE(),INTERVAL 1 MONTH)

加算にはDATE_ADD()関数、減算にはDATE_SUB()関数です。
44
33
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
44
33