0

I am trying to find the work experience of employees in ORACLE SQL Developer.

I have the following columns in the table employees: Hire_Date(DD-MM-YY), First_name, Last_Name, Employee_id, Salary, Manager_ID and so on.

I guess I need to apply some conversion but I'm not sure about the method or how to convert it.


I tried to subtract hire_date from Sysdate.

Select, Employee_id, First_name, Hire_Date, (Sysdate-Hire_Date) as year_Exp
from employees;

I am getting the output as

Actual result: 5966.52.333333333333333333333333333333333

Expected result: 5 Years or relevant years of experience

Nitin Gore
  • 3
  • 1
  • 5

1 Answers1

0

Try it, It will help for you:

--Oracle 11g Express Edition
-- Put your Oracle SQL statement here and execute it

  select trunc(months_between(sysdate,hiredate)/12) year,
       trunc(mod(months_between(sysdate,hiredate),12)) month,
       trunc(sysdate-add_months(hiredate,trunc(months_between(sysdate,hiredate)/12)*12+trunc(mod(months_between(sysdate,hiredate),12)))) day
from (Select to_date('15122000','DDMMYYYY') hiredate from dual);
smita
  • 298
  • 1
  • 4
  • 17