以 2008-11-2113:45:25 为例:

 

格式

说明

结果

yy

两位年

08

yyy

三位年

008

yyyy

四位年

2008

mm

数字表示

11

mon

字符集简写表示

11月,若是英文版,则显示nov

month

字符集全写表示

11月,若是英文版,则显示november

dd

当月第几天

21

ddd

当年第几天

21

dy

当周第几天简写

星期五,若是英文版,则显示fri

day

当周第几天全写

星期五,若是英文版,则显示friday

ddspth

拼写

twenty-first

hh

12小时进制

01 (范围:1:00:00 - 12:59:59)

hh24

24小时进制

13 (范围:0:00:00 - 23:59:59)

mi

60进制

45

ss

60进制

25

其它

Q

季度

4

WW

当年第几周

44

W

当月第几周

1

例如:

select to_char(sysdate) "默认",
to_char(sysdate,'dd-mm-yyyy') "dd-mm-yyyy",
to_char(sysdate,'yyyy-mm-dd') "yyyy-mm-dd",
to_char(sysdate,'yy') "yy",
to_char(sysdate,'yyy') "yyy",
to_char(sysdate,'yyyy') "yyyy",
to_char(sysdate,'mm') "数字月",
to_char(sysdate,'mon') "简写月",
to_char(sysdate,'month') "全写月",
to_char(sysdate,'d') "当周第几天",
to_char(sysdate,'dd') "当月第几天",
to_char(sysdate,'ddd') "当年第几天",
to_char(sysdate,'dy') "当周第几天简写",
to_char(sysdate,'day') "当周第几天全写",
to_char(sysdate,'ddspth') "ddspth",
to_char(sysdate,'Q') "季度",
to_char(sysdate,'WW') "当年第几周",
to_char(sysdate,'W') "当月第几周",
to_char(sysdate,'hh24:mi:ss') "hh24:mi:ss",
to_char(sysdate,'yy-mm-dd') "yy-mm-dd",
to_char(sysdate,'yyyy-mm-dd') "yyyy-mm-dd",
to_char(sysdate,'yy-mm-dd hh12:mi:ss') "yy-mm-dd hh12:mi:ss",
to_char(sysdate,'yyyy-mm-dd hh12:mi:ss') "yyyy-mm-dd hh12:mi:ss",
to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') "yyyy-mm-dd hh24:mi:ss"
from dual;

相关文章:

  • 2021-10-17
  • 2022-01-11
  • 2021-08-26
  • 2022-12-23
  • 2021-09-02
  • 2021-08-14
  • 2022-01-29
猜你喜欢
  • 2021-11-27
  • 2021-10-13
  • 2021-07-16
  • 2022-03-02
  • 2022-02-14
  • 2021-12-21
  • 2022-12-23
相关资源
相似解决方案