MySQL 时间日期函数

(0 comments)

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)
Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required