MySQL时间函数-获取当前时间-时间差


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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM