mysql 将时间戳转换成日期格式

create_time 代表你的时间字段

FROM_UNIXTIME(create_time) 

转换前

           

 

 转换后

      

--------------------------------------------------------------------------------------------------

第二种 常用

SELECT FROM_UNIXTIME(1500109248, '%Y-%m-%d %H:%i:%S')
返回:2017-07-15 17:00:48

 

 -------------------------------------------------------------------------------------------------------

#查询当日新付费用户sql
SELECT
a.id,
 a.member_id,
 b.realname,
 b.mobile,
 FROM_UNIXTIME( a.pay_time, '%Y-%m-%d %H:%i:%s' ) AS pay_time 
FROM
 rf_member_buy_set_meal AS a
 LEFT JOIN rf_member AS b ON a.member_id = b.id 
WHERE
 a.id in () and 
 a.city_code = 440300 and
 a.pay_status =1 and 
 a.order_status in (1,0) and 
 a.order_type =1 
 AND ( a.pay_time >= '1620230400' AND a.pay_time <= '1620316799' )
 
#查询用户购买一次套餐记录
SELECT count(*) as total ,id,member_id  from rf_member_buy_set_meal  where city_code = 440300 and  pay_status =1  and order_type = 1 GROUP BY member_id  HAVING total =1

 

 

 

 

 

 转载 https://blog.csdn.net/asenseof/article/details/108468468

posted @ 2021-05-07 10:45  搬砖小伙子  阅读(2509)  评论(0编辑  收藏  举报