[Fixed]-Compare datetime field with date in django orm

1👍

convert start_date into python date object then do the filtering.

Example

from datetime import datetime
[1]:start_date = '2017-02-03'
[2]:start_date = datetime.strptime(startdate, '%Y-%m-%d')
[3]:start_date.year ## 2017

OutputData = Entity.objects.filter(created_on__year=start_date.year,
created_on__month=start_date.month,created_on__day=start_date.day).count()
👤Cadmus

Leave a comment