mysql時間格式化

2021-06-25 23:44:53 字數 1256 閱讀 2267

date_forma t(date, format) 根據格式串format 格式化日期或日期和時間值date,返回結果串。

可用date_format( ) 來格式化date 或datetime 或時間格式的字串值,以便得到所希望的格式。根據format字串格式化date值:

%s, %s 兩位數字形式的秒( 00,01, . . ., 59)

%i 兩位數字形式的分( 00,01, . . ., 59)

%h 兩位數字形式的小時,24 小時(00,01, . . ., 23)

%h, %i 兩位數字形式的小時,12 小時(01,02, . . ., 12)

%k 數字形式的小時,24 小時(0,1, . . ., 23)

%l 數字形式的小時,12 小時(1, 2, . . ., 12)

%t 24 小時的時間形式(h h : m m : s s)

%r 12 小時的時間形式(hh:mm:ss am 或hh:mm:ss pm)

%p am 或p m

%w 一周中每一天的名稱( s u n d a y, monday, . . ., saturday)

%a 一周中每一天名稱的縮寫( sun, mon, . . ., sat)

%d 兩位數字表示月中的天數( 00, 01, . . ., 31)

%e 數字形式表示月中的天數( 1, 2, . . ., 31)

%d 英文本尾表示月中的天數( 1st, 2nd, 3rd, . . .)

%w 以數字形式表示週中的天數( 0 = s u n d a y, 1=monday, . . ., 6=saturday)

%j 以三位數字表示年中的天數( 001, 002, . . ., 366)

% u 周(0, 1, 52),其中sunday 為週中的第一天

%u 周(0, 1, 52),其中monday 為週中的第一天

%m 月名(j a n u a r y, february, . . ., december)

%b 縮寫的月名( j a n u a r y, february, . . ., december)

%m 兩位數字表示的月份( 01, 02, . . ., 12)

%c 數字表示的月份( 1, 2, . . ., 12)

%y 四位數字表示的年份

%y 兩位數字表示的年份

%% 直接值「%」

select date_format(日期字段,』%y-%m-%d』) as 『日期』 from test

mysql時間格式化

date forma t date,format 根據格式串format 格式化日期或日期和時間值date,返回結果串。可用date format 來格式化date 或datetime 值,以便得到所希望的格式。根據format字串格式化date值 s,s 兩位數字形式的秒 00,01,59 i 兩...

mysql時間格式化

date format date,format 根據格式串format 格式化日期或日期和時間值date,返回結果串。可用date format 來格式化date 或datetime值,以便得到所希望的格式。根據format字串格式化date值 s,s 兩位數字形式的秒 00,01,59 i 兩位數...

mysql時間格式化

在oracle裡面將時間to char time,yyyymmddhh 在mysql裡面不能這樣格式化,請問有沒辦法將mysql裡面表字段格式化成 yyyymmddhh 的呀 date forma t date,format 根據格式串format 格式化日期或日期和時間值date,返回結果串。可用...