计算时间戳记少于24小时的行 [英] Counting rows where a timestamp is less than 24 hours old

查看:188
本文介绍了计算时间戳记少于24小时的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于以下查询,我该如何计算datesent少于24小时的行数? (字段datesent是时间戳).

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).

预先感谢

约翰

  $message = "SELECT datesent, recipient
               FROM privatemessage 
              WHERE recipient = '$u'";


  $messager = mysql_query($message);

$messagearray = array(); 

推荐答案

使用:

SELECT COUNT(*) AS cnt
  FROM PRIVATEMESSAGE pm
 WHERE pm.datesent >= DATE_SUB(NOW(), INTERVAL 1 DAY)

这篇关于计算时间戳记少于24小时的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆