将日期格式化为单词

时间:2016-11-11 22:04:01

标签: sql oracle date-formatting

我希望显示部门员工达到二十周年工作周年的日期。这就是我所拥有的:

    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

等等。但是我希望以这种格式显示日期:1月21日,1928年。我如何格式化日期?

1 个答案:

答案 0 :(得分:2)

我认为这是你在寻找的。 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; 日期格式化。查看oracle的官方文档页面

http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions180.htm

class someClass:
    def objFunction(self, weights):
        return [self.obj1(weights), self.obj2(weights), self.obj3(weights)]

    def asf(self, f):

        def obj(x):
            return np.max(np.array(f(x[0],x[1],x[2])))+0.00001*np.sum(f(x[0],x[1],x[2]))

        res=minimize(obj, 
        [0.3,0.3,0.4], method='SLSQP'
        ,jac=ad.gh(obj)[0],options = {'disp':True, 'ftol': 1e-20,
                                    'maxiter': 1000})
        return res