天天看点

MySQL中DATA_FORMAT函数的用法

一、api例子

date_format(now(),'%b %d %y %h:%i %p')

date_format(now(),'%m-%d-%y')

date_format(now(),'%d %b %y')

date_format(now(),'%d %b %y %t:%f')

dec 29 2008 11:45 pm

12-29-2008

29 dec 08

29 dec 2008 16:25:46.635

二、现实中的例子

select date_format(sysdate(),'%y-%m-%e %h:%i:%s')

2012-12-28 09:50:21

select date_format('2012-01-01','%y-%m-%e %h:%i:%s')

2012-01-1 00:00:00

api地址:http://www.w3school.com.cn/sql/func_date_format.asp