JoseFranc
JoseFranc

Reputation: 213

How to get the difference in years between two dates in sql - ORACLE?

I want to make a query in Oracle that shows all the records in which the employees are in the 'IT DEPARTMENT' and have been working between 3 and 8 years.

I have the table:

enter image description here

The IT Department has ID 60 in the table, how can I do the query with records from the table? Please help! :(

Upvotes: 0

Views: 138

Answers (1)

OldProgrammer
OldProgrammer

Reputation: 12169

Try this:

select * from job_history
where end_date - start_date between  1095 and 2920
and department_id = 60;

1095 = 3*365

2920 = 8*365

Upvotes: 1

Related Questions