Reputation: 3
I have a column in my database which is named date... in this column i am storing a datetime value...now when i want to filter the table according to date value(only date and not datetime)..say i want to retrieve all coloums having a particular date..then how can i apply such filtering(i.e getting date out of datetime column)
Upvotes: 0
Views: 158
Reputation: 35619
You can also do:
MyModel.objects.filter(date__gte=date, date__lt=date+datetime.timedelta(1))
Not sure which is faster, this or dappawit's solution.
Upvotes: 0
Reputation: 12570
For example, to match March 18, 2011:
queryset = MyModel.objects.filter(date__year=2011, date__month=3, date__day=18)
Django docs: http://docs.djangoproject.com/en/1.2/ref/models/querysets/#year
Upvotes: 1