问题描述:
MySQL时间戳查询当天数据无结果
select * from table where
date_format(FROM_UNIXTIME(create_date),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
原因分析:
java 自动生成的时间戳是13位,经确到微秒。MySQL 查询时间戳为10位,精确到秒。所以无法查询到结果解决方案:
数据除以1000,并四舍五入,使其转换成10位的时间戳 select * from table where
date_format(FROM_UNIXTIME(ROUND(create_time/1000)),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')