MySQL时间函数-获取当前时间-时间差
时间:2017-03-16 23:48:32
收藏:0
阅读:1212
MySQL中获取当前时间为now(),不同于sqlserver getdate()。
SQLServer转MySQL除变化top 1 -> limit 1之后报错:
select 1 from record_visitor where visitor_ip=‘‘ and datediff(mi,visitor_time,getdate())<=30 limit 1
[Err] 1582 - Incorrect parameter count in the call to native function ‘datediff‘
搜索了是MySQL->DATEDIFF只计算到天的单位。
正确写法:
select 1 from record_visitor where visitor_ip=‘‘ and TIMESTAMPDIFF(MINUTE,visitor_time,now())<=30 limit 1
评论(0)