Let's say in my employee table I have a column 'hire_date', I want the employee who has the tenure of 1-3 months or simply only 3-month old employees by 'hire_date'.
I tried this:
Employee::whereDate('hire_date', '<=', Carbon::now()->subMonths(3))
->orderBy('hire_date', 'desc')
->get();
But it returns all the employees.
I printed the raw query and it is just going back 3 months from the current date and then fetching the records.
date(`hire_date`) <= 2020-02-22 //whereDate('hire_date', '<=', Carbon::now()->subMonths(3)
What am I doing wrong? Any Idea to achieve this?
Example: Jhon an employee was hired in a company on 01/Feb/2020. So when he completes his 3 months in the company I want to do something by fetching his records.