Counting rows where a timestamp is less than 24 hours old

前端 未结 4 1326
野的像风
野的像风 2021-01-03 19:28

For the query below, how could I count the number of rows where datesent is less than 24 hours old? (The field datesent is a timestamp).

T

4条回答
  •  时光说笑
    2021-01-03 20:07

    You can use the DATE_SUB function. Subtract one day from the current date in the where clause.

    Something like

    DATE_SUB(NOW(), INTERVAL 1 DAY)
    

    EDIT: changed CURTIME() to NOW()

提交回复
热议问题