1 select DATE_FORMAT(dtl.transdate,'%Y-%m-%d') as transdate, 2 right(DATE_FORMAT(concat(transdate,transtime),'%Y-%m-%d %H:%i:%s'),8) as 3 transtime,dt ...
1 select DATE_FORMAT(dtl.transdate,'%Y-%m-%d') as transdate, 2 right(DATE_FORMAT(concat(transdate,transtime),'%Y-%m-%d %H:%i:%s'),8) as 3 transtime,dtl.custname,dtl.stuempno,dtl.deviceid,dtl.devtype,dev.devicename,a.names as areaname 4 from t_devicedtl dtl 5 left join t_device dev on dev.deviceid=dtl.deviceid 6 left join t_area a on a.id=dev.areaid
- DATE_FORMAT(dtl.transdate,'%Y-%m-%d') :例如將資料庫中的transdate欄位20200123進行格式化,結果為:2020-01-23
- DATE_FORMAT(concat(transdate,transtime),'%Y-%m-%d %H:%i:%s'):例如欄位transdate:20200123,欄位transtime:122359,結果為:2020-01-23 12:23:59
- right(DATE_FORMAT(concat(transdate,transtime),'%Y-%m-%d %H:%i:%s'),8) :取格式化後取後8位,結果為:12:23:59