mysql中怎麼實現oracle中的to_char和to_date

來源:互聯網
上載者:User

標籤:

oracle中的轉字元:to_char()

oracle中的轉日期:to_date()

mysql中的轉字元:date_format(date,‘%Y-%m-%d‘)   相當於oracle中的to_char()

mysql中的轉日期:str_to_date(date,‘%Y-%m-%d‘)    相當於oracle中的to_date()

%Y:代表四位年  (相當於oracle中的yyyy)注意這裡嚴格大寫。

%m:代表兩位月份(01,02……10,12)

%d:代表月份中兩位天數(01,02……30,31)

%e:代表月份中的天數(1,2,3,4……30,31)

===================================================

%H:代表24小時的小時格式(00,01,02……12,13,14……20,21,22,24)

%k:代表24小時的小時格式(0,1,2……12,13,14……20,21,22,24)

%h:代表12小時的小時格式(01,02,03……11,12)

%l:代表12小時的小時格式(1,2,3……11,12)

%i:代表分鐘(格式為00,01,02……58,59)

 

%r:表示12小時的時間格式(hh:mm:ss)

%T:表示24小時的時間格式(hh:mm:ss)

 

%s和%S:都表示時間秒。

mysql中怎麼實現oracle中的to_char和to_date

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.