1

What needs to be changed in the below queries?. i want all those employees whose date_of_leaving is null or the date_of_leaving is in between the past 60 days or the date_of_leaving is greater than or equal to the Date.today or current date.

employees = @company.employees.where('date_of_leaving BETWEEN ? AND ? OR date_of_leaving IS NULL OR date_of_leaving IS >= Date.today', Date.today - 60, Date.today)

i tried in another way also like below.

employees = Company.find(4).employees.where('date_of_leaving BETWEEN ? AND ? OR date_of_leaving IS NULL OR date_of_leaving IS >= ?', Date.today - 60, Date.today,Date.today)

1 Answer 1

1

I think your problem is the phrase IS >= .

You shouldn't use is with comparison operators. Just the operator. Take out that and it looks good otherwise.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.