2.20 Y,YYY 返回有逗号分隔显示的年
SQL> select to_char(SYSTIMESTAMP,'Y,YYY') from dual; TO_CHAR(SYSTIMESTAMP,'Y,YYY') ----------------------------- 2,015
2.21 Y/YY/YYY/YYYY 以指定长度返回日期的年份
SQL> select to_char(sysdate,'Y') from dual; TO_CHAR(SYSDATE,'Y') -------------------- 5 SQL> select to_char(sysdate,'YY') from dual; TO_CHAR(SYSDATE,'YY') --------------------- 15 SQL> select to_char(sysdate,'YYY') from dual; TO_CHAR(SYSDATE,'YYY') ---------------------- 015 SQL> select to_char(sysdate,'YYYY') from dual; TO_CHAR(SYSDATE,'YYYY') ----------------------- 2015
2.22 W 返回指定日期在当月中的第X周(范围:1-5)
SQL> select to_char(sysdate,'W') from dual; TO_CHAR(SYSDATE,'W') -------------------- 4
2.23 WW 返回指定日期在当年中的第X周(范围:1-53)
SQL> select to_char(sysdate,'WW YYYY-MM-DD') from dual; TO_CHAR(SYSDATE,'WWYYYY-MM-DD' ------------------------------ 52 2015-12-27
2.24 IW 指定日期在当年中第X周(范围:1-52或1-53(润年))
SQL> select to_char(sysdate,'IW YYYY-MM-DD') from dual; TO_CHAR(SYSDATE,'IWYYYY-MM-DD' ------------------------------ 52 2015-12-27
2.25 Q 返回指定日期的季度(范围:1-4)
SQL> select to_char(sysdate,'Q YYYY-MM-DD') from dual; TO_CHAR(SYSDATE,'QYYYY-MM-DD') ------------------------------ **4** 2015-12-27
2.26 DY 返回星期简写(也可以用DAY)
SQL> select to_char(sysdate,'DY YYYY-MM-DD') from dual; TO_CHAR(SYSDATE,'DYYYYY-MM-DD' ------------------------------ 星期日 2015-12-27 SQL> alter session set nls_language='AMERICAN'; Session altered SQL> select to_char(sysdate,'dy') from dual; TO_CHAR(SYSDATE,'DY') --------------------- sun
来源:https://www.cnblogs.com/cainiao-Shun666/p/6877672.html