MySQL日期和字串轉換函式例項

2021-12-30 07:50:52 字數 651 閱讀 3312

str_to_date(date,'%y-%m-%d')----->相當於oracle中的to_char();

例子:insert into

t_order(order_time)

values

(str_to_date('2018-05-06','%y-%m-%d'))date_format(date,'%y-%m-%d')----->相當於oracle中的to_date();

例子:select date_format(order_time, '%y-%m-%d')from t_order%y:代表4位的年份%y:代表2為的年份?%m:代表月, 格式為(01……12) ?%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)

JS 日期字串 轉換函式

將string型別解析為date型別.parsedate 2006 1 1 return new date 2006,0,1 parsedate 2006 1 1 return new date 2006,0,1 parsedate 2006 1 1 15 14 16 return new date...

日期和字串互相轉換

1.日期與字串的轉換 select to char sysdate,yyyy mm dd hh24 mi ss as nowtime from dual 日期轉化為字串 select to date 2004 05 07 13 23 44 yyyy mm dd hh24 mi ss from dua...

Oracle 字串和日期轉換

yyyy 完整年 yyy 完整年後3位數 yy 完整年後2位數 y 完整年最1位數 month 月 全稱 mm 當年第幾月 ddd 當年第幾天 dd 當月第幾天 day星期幾 全稱 d 星期幾 每週從禮拜天開始 1 7 hh 當前小時 12小時制 hh24 當前小時 24小時制 mi 分鐘 ss 秒...