What is the django query to find the records where the searching date is between two columns are not?

"select * from resource_management 
 where ('2015-11-08' between employee_effective_start_date and
                             employee_effective_end_date )"

I want the above sql query to be executed using Django orm(QUERYS) can anyone please help me how it should be framed in Django. Is it using annotation!

Thanks for dropping by.

1 answer

  • answered 2018-11-08 07:36 schwobaseggl

    No annotations needed. Assuming employee_effective_start_date and employee_effective_end_date are (date) fields of a ResourceManagement model, something as trivial as


    will work. If you want to be as locale and db independent as possible you can replace '2015-11-08' by 'datetime(2015, 11, 8)'.