1.获取当前日期的年月日
select to_char(sysdate,‘yyyy‘) from dual;
select to_char(sysdate,‘mm‘) from dual;
select to_char(sysdate,‘dd‘) from dual;
2.显示所有员工的姓名、入职的年份和月份,按入职日期所在的月份排序,若月份相同则按入职的年份排序。
SQL> select extract (year from date ‘2015-05-04‘) year, extract (month from date‘2015-05-04‘) month, extract (day from date ‘2011-05-04‘) day from dual;
YEAR MONTH DAY
---------- ---------- ----------
5 4
原文:https://www.cnblogs.com/brianlai/p/10353224.html