mysql日付/時刻を文字列に変換

614 ワード

     2016-05-13 16:07:50      20160513

date_format

SELECT 
    phone, DATE_FORMAT(time, '%Y%m%d%H%i%s')
FROM
    user
WHERE
    phone = 'xxxxxxxx'; 
    #20160513160750

SELECT 
    phone, DATE_FORMAT(time, '%Y%m%d')
FROM
    user
WHERE
    phone = 'xxxxxxxx'               
#20160513
SELECT 
	reportStatus, date_format(reportDateTime, '%Y-%m-%d %H:%i:%s') reportDateTime
FROM
	doorSensorDevice
WHERE
	deviceId = #{deviceId}
		AND reportStatus IS NOT NULL
ORDER BY reportDateTime DESC
LIMIT #{startNum} , #{pageSize}