2017-06-19 58 views
0

我想人們選擇在五月聘請,但我(MONTH(HIRE_DATE)= 05)不工作SQL MONTH()不工作

SELECT EMPLOYEE_ID AS "Employee Number", LAST_NAME ||', '|| FIRST_NAME AS 
"Full Name", JOB_ID, '[' || TO_CHAR(HIRE_DATE, 'Month fmddth "of" YYYY') ||']' AS "Hire Date" 
FROM EMPLOYEES 
WHERE (HIRE_DATE NOT BETWEEN TO_DATE('01/01/1994','DD/MM/YYYY') AND 
TO_DATE('31/12/1995','DD/MM/YYYY')) AND 
(MONTH(HIRE_DATE) = 05) 
+4

如果在[Oracle手冊](https://docs.oracle.com/database/121/SQLRF/toc.htm)中找到'month()' –

+0

[如何將日期轉換爲月份號?](https://stackoverflow.com/questions/14041200/how-to-convert-date-into-month-number) –

回答

1

有一個在Oracle中沒有MONTH()功能。

to_char(hire_date, 'mm') = '05'extract (month from hiredate) = 5都應該工作。