Counting rows where a timestamp is less than 24 hours old

前端 未结 4 1362
野的像风
野的像风 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:14

    $message="select count(1)
    from privatemessage
    where datesent>=date_sub(now(), 24 hours)
    and recipient='$u'"
    

    http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add

提交回复
热议问题