// 注意数据库服务时区一定要正确符合本地时区
select now(); //发现跟系统时间不一致就是 时区问题
// 解决时区问题
show variables like '%zone%'
如果 system_time_zone 是 CST ,time_zone 是 system
则 set time_zone = '+08:00' && 客户端jdbc链接 时区也需要注意并设置
//求平均时间
select FROM_UNIXTIME(avg(unix_timestamp(endtime)),'%Y-%m-%d') as avgDate,
FROM_UNIXTIME(avg(unix_timestamp(endtime)),'%T') as avgTime
from (select '2021-11-16 08:10:30') as endtime
union all
select '2021-11-18 08:40:30') as endtime)
select time_to_sec('01:00:00')
select sec_to_time('3600')
mysql 5.7 求平均日期
最新推荐文章于 2022-12-13 22:05:59 发布