2👍
✅
The year
, month
and day
fields of the datetime object are available to you, but after testing here it doesn’t seem to allow the additional __gte
application to the field.
This will work:
now = datetime.now()
results = MyTable.objects.filter(datetime_field__year=now.year, datetime_field__month=now.month, datetime_field__day=now.day)
But doesn’t allow gte.
you can always just create a datetime starting at 0:00
now = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
results = MyTable.objects.filter(datetime_field__gte=now)
Source:stackexchange.com