MySQL 时间日期函数

  | 转载时请务必以超链接形式标明文章原文链接和作者信息及本版权声明。
原文链接:http://www.liaojl.com/archives/2009/12/mysql.html

1. 数据表中包含时间戳信息时,查询与当前时间相隔30分钟(1800秒)内的记录:

SELECT * FROM trunk_records 
where UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(record_time)<=1800

2. 查询当天的记录

SELECT * FROM trunk_records where DATE(NOW()) = DATE(record_time)

Leave a comment

Archives

Creative Commons License
This blog is licensed under a Creative Commons License.