Mysql DATE_SUB(NOW(), INTERVAL 1 DAY) 24 hours or weekday?

前端 未结 2 940
攒了一身酷
攒了一身酷 2020-12-14 08:47

I am trying to get the totaal amount of registerd users per day. At the moment i am using this

$sql = \"SELECT name, email FROM users WHERE DATE_SUB(NOW(), I         


        
2条回答
  •  一整个雨季
    2020-12-14 09:36

    I think you need

    SELECT
        name,
        email
    FROM users
    WHERE DATE(lastModified) = DATE( NOW() )
    

    This effectively "rounds to the date only" and will therefore only match records "since midnight".

提交回复
热议问题