1.学习网站: http://www.w3school.com.cn/sql/func_date_format.asp
2.sql示例:
SELECT DATE_FORMAT(NOW(),'%Y') YEAR;
SELECT DATE_FORMAT(NOW(),'%y') YEAR;
SELECT DATE_FORMAT(NOW(),'%m') MONTH;
SELECT DATE_FORMAT(NOW(),'%d') DAY;
SELECT DATE_FORMAT(NOW(),'%T') TIME;
SELECT DATE_FORMAT(NOW(),'%Y-%m-%d') DATE;
SELECT DATE_FORMAT(NOW(),'%Y-%m-%d-%T') DATETIME;
3.实战写法:
SELECT * FROM BL_BILL WHERE BILL_STATUS='REPAYING' AND STR_TO_DATE(DATE_FORMAT(BILL_GMT_TIME,'%Y-%c-%d'), '%Y-%m-%d' ) <= '2015-10-30 19:22:12.689' AND DELETE_TAG = 'NO';