我想显示各部门员工工作二十周年纪念日的日期。这就是我所拥有的:
select e.last_name, e.department_id, add_months(min(h.start_date), 240) as "20 Year Anniversary"
from employees e
inner join job_history h
on h.employee_id = e.employee_id
group by e.department_id, e.last_name;
这显示:
Last_Name Department_ID 20 Year Anniversary
1 Hartstein 20 17-FEB-16
2 Bob 90 21-SEP-09
等等。但我想以这种格式显示日期:一月二十一号,十九号八十二号。我该如何格式化日期?
最佳答案
我想这就是您正在寻找的。 TO_CHAR
日期格式。查看oracle官方文档页面
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions180.htm
select e.last_name, e.department_id,to_char(add_months(min(h.start_date), 240),'Month fmDdsp, Year') as "20 Year Anniversary"
from employees e
inner join job_history h
on h.employee_id = e.employee_id
group by e.department_id, e.last_name;
关于sql - 将日期格式化为单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40556942/