mysql類似於oracle的to_char() to_date()方法

mysql日期和字符相互轉換方法mysql

date_format(date,'%Y-%m-%d')    -------------->oracle中的to_char();sql

str_to_date(date,'%Y-%m-%d')     -------------->oracle中的to_date();oracle

 

%Y:表明4位的年份orm

%y:表明2爲的年份form

 

%m:表明月, 格式爲(01……12)  date

%c:表明月, 格式爲(1……12)方法

 

%d:表明月份中的天數,格式爲(00……31)  時間

%e:表明月份中的天數, 格式爲(0……31) 字符

 

%H:表明小時,格式爲(00……23)  日期

%k:表明 小時,格式爲(0……23)  

%h: 表明小時,格式爲(01……12)  

%I: 表明小時,格式爲(01……12)  

%l :表明小時,格式爲(1……12)

  

%i: 表明分鐘, 格式爲(00……59) 

 

%r:表明 時間,格式爲12 小時(hh:mm:ss [AP]M)  

%T:表明 時間,格式爲24 小時(hh:mm:ss) 

 

%S:表明 秒,格式爲(00……59)  

%s:表明 秒,格式爲(00……59) 

相關文章
相關標籤/搜索