Oracle-如何检查输入的日期大于9个月

时间:2018-06-27 05:45:13

标签: oracle validation date

需要检查员工从入职之日起是否已经过了9个月。

2 个答案:

答案 0 :(得分:0)

创建示例数据为:

    create table employee(id number,hire_date date);
    insert into employee values(1,'12-APR-2017');
    insert into employee values(2,'18-Oct-2017');
    insert into employee values(3,'01-Jan-2018');

    select id,hire_date, case when months_between(sysdate,hire_date) > 9 then 'Crossed' else 'Not-Crossed'  end is_crossed from employee;

输出将是:

ID  HIRE_DATE   IS_CROSSED
1   12-APR-17   Crossed
2   18-OCT-17   Not-Crossed
3   01-JAN-18   Not-Crossed

答案 1 :(得分:0)

选择to_char(TO_DATE(joindt,'DD / MM / RRRR'))

谢谢大家。我有解决办法。