首页 > 数据库技术 > 详细

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

时间:2016-06-03 14:11:27      阅读:182      评论:0      收藏:0      [点我收藏+]

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) ; 

 

 

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

原文:http://www.cnblogs.com/wangdahai/p/5555977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!