1. 程式人生 > >mysql 獲取時間日期後,如何在資料庫裡去掉小數點後面的零

mysql 獲取時間日期後,如何在資料庫裡去掉小數點後面的零

SELECT
sds_gps_log.ID,
sds_gps_log.DeviceID,
sds_gps_log.Lng,
sds_gps_log.Lat,
DATE_FORMAT(sds_gps_log.Time,'%Y-%m-%d %T') AS Time,
sds_gps_log.ACC,
sds_gps_log.Direct,
sds_gps_log.Speed,
sds_gps_log.High,
sds_gps_log.Idle,
sds_gps_log.Odometer,
sds_gps_log.Satalite
FROM
sds_gps_log
WHERE 
sds_gps_log.Time between '2017-11-29 17:30:45' AND '2017-11-29 17:31:25' 

在資料庫裡使用DATE_FORMAT();格式化時間,就可以在Java後臺獲取正確的時間日期,不帶有.0的尾數。相對那些在後臺用時間戳去掉小數點在效率上更快

請測可行!