My Blog List

Sunday, March 17, 2013

DATE_FORMAT, STR_TO_DATE


-- datetime, date to str

SELECT DATE_FORMAT(REG_DATE, '%Y-%m-%d %H:%i:%s') FROM TB_FILE;

SELECT DATE_FORMAT(REG_DATE, '%Y-%m-%d %H:%i:%s') FROM TB_FILE;

-- str to datetime

select STR_TO_DATE('2011-04-30 15:13:25', '%Y-%m-%d %H:%i:%s');

--

SELECT NOW();

SELECT DATE_ADD(NOW(), INTERVAL -1 DAY);

No comments:

Post a Comment