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) as3 transtime,dtl.custname,dtl.stuempno,dtl.deviceid,dtl.devtype,dev.devicename,a.names as areaname4 from t_devicedtl dtl5 left join t_device dev on dev.deviceid=dtl.deviceid6 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
没有评论:
发表评论