mysql查询时间戳和日期的转换


mysql提供了两个函数:

 from_unixtime(time_stamp)   ->  将时间戳转换为日期
 
 unix_timestamp(date)   ->  将指定的日期或者日期字符串转换为时间戳
如果要查询当天的订单的记录:
[plain] 
select count(*) from b_order Where  date_format(from_unixtime(create_time),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')  
 
也可以这样:
[plain] 
select count(*) from b_order Where  create_time >= unix_timestamp('2013-10-24 00:00:00') and create_time <=  unix_timestamp('2013-10-24 23:59:59') ; 

 

 


免责声明!

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



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