首页 > 代码库 > MySQL日期函数的用法几则

MySQL日期函数的用法几则

1.将Date类型变成年月日时分秒的形式

select date_format(claimDate,%Y-%m-%d %H:%i:%s) as claimdate from t1

 

2.只要年月日的形式

select date_format(claimdate,%Y-%m-%d) as newdate from t1

 

3.获得星期几(英语如Monday,Tuesday...)

select DAYNAME(claimdate) as weekday from t1

 

MySQL日期函数的用法几则