ORA-00904:“MONTH”:标识符无效

时间:2017-09-16 04:43:26

标签: mysql oracle

我正在尝试获取当月出生的所有员工的列表。我已存储日期,如'16 -Sep-2017',每当我运行我的代码时,它会给我错误ORA-00904:“MONTH”:不合法的识别符。 这是我的代码:

SELECT * from employee1 where month(birth_date)=month(now);

SELECT * FROM employee1 WHERE month(bithdate) = MONTH(CURRENTTIME());

SELECT  * FROM employee1
WHERE MONTH(STR_TO_DATE(birth_date, '%d-%m-%Y')) = MONTH(NOW());

SELECT * FROM EMPLOYEE1 WHERE STR_TO_DATE(BIRTH_DATE,'%d-%m-%y')=MONTH(CURRENT_DATE);

select * from employee1 
where CAST(SUBSTRING(birth_date,'%d-%m-%y')AS unsigned)=MONTH(CURRENT_DATE);

select * from employee1 
where CAST(SUBSTRING(birth_date,'%d-%m-%y')AS varchar2)=MONTH(CURRENT_DATE);

select * from employee1 where to_date('birthdate', 'dd-mon-yyyy')=month(current_date);

我已经尝试了所有可能性,但每次我遇到错误的无效月份标识符

1 个答案:

答案 0 :(得分:4)

oracle表单是extract(表达式中的元素),例如select dual(来自current_date的月份)monthnumber来自dual;