diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 1455ba6..d215f4c 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -8,7 +8,7 @@ import datetime
 from itertools import repeat
 
 from django.utils import tree
-from django.db.models.fields import Field
+from django.db.models.fields import Field, DateTimeField
 from django.db.models.sql.datastructures import EmptyResultSet, FullResultSet
 
 # Connection types
@@ -145,6 +145,10 @@ class WhereNode(tree.Node):
             except EmptyShortCircuit:
                 raise EmptyResultSet
         else:
+            # If the value is a datetime value, we need to take care converting it into
+            # proper db datettime type.
+            if isinstance(params_or_value, datetime.datetime):
+                params_or_value = connection.ops.value_to_db_datetime(params_or_value)
             params = Field().get_db_prep_lookup(lookup_type, params_or_value,
                 connection=connection, prepared=True)
         if isinstance(lvalue, tuple):
diff --git a/tests/modeltests/timezones/models.py b/tests/modeltests/timezones/models.py
index 9296edf..f0cc792 100644
--- a/tests/modeltests/timezones/models.py
+++ b/tests/modeltests/timezones/models.py
@@ -6,6 +6,13 @@ class Event(models.Model):
 class MaybeEvent(models.Model):
     dt = models.DateTimeField(blank=True, null=True)
 
+class Session(models.Model):
+    name = models.CharField(max_length=20)
+
+class SessionEvent(models.Model):
+    dt = models.DateTimeField()
+    session = models.ForeignKey(Session, related_name='events')
+
 class Timestamp(models.Model):
     created = models.DateTimeField(auto_now_add=True)
     updated = models.DateTimeField(auto_now=True)
diff --git a/tests/modeltests/timezones/tests.py b/tests/modeltests/timezones/tests.py
index dc9cfb3..8184059 100644
--- a/tests/modeltests/timezones/tests.py
+++ b/tests/modeltests/timezones/tests.py
@@ -25,7 +25,7 @@ from django.utils.tzinfo import FixedOffset
 from django.utils.unittest import skipIf, skipUnless
 
 from .forms import EventForm, EventSplitForm, EventModelForm
-from .models import Event, MaybeEvent, Timestamp
+from .models import Event, MaybeEvent, Session, SessionEvent, Timestamp
 
 
 # These tests use the EAT (Eastern Africa Time) and ICT (Indochina Time)
@@ -231,6 +231,28 @@ class LegacyDatabaseTests(BaseDateTimeTests):
             'dt__max': datetime.datetime(2011, 9, 1, 23, 20, 20),
         })
 
+    def test_query_annotation(self):
+        # Only min and max make sense for datetimes.
+        morning = Session.objects.create(name='morning')
+        afternoon = Session.objects.create(name='afternoon')
+        SessionEvent.objects.create(dt=datetime.datetime(2011, 9, 1, 23, 20, 20), session=afternoon)
+        SessionEvent.objects.create(dt=datetime.datetime(2011, 9, 1, 13, 20, 30), session=afternoon)
+        SessionEvent.objects.create(dt=datetime.datetime(2011, 9, 1, 3, 20, 40), session=morning)
+        morning_min_dt = datetime.datetime(2011, 9, 1, 3, 20, 40)
+        afternoon_min_dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
+        self.assertQuerysetEqual(
+                Session.objects.annotate(dt=Min('events__dt')).order_by('dt'),
+                [morning_min_dt, afternoon_min_dt],
+                transform=lambda d: d.dt)
+        self.assertQuerysetEqual(
+                Session.objects.annotate(dt=Min('events__dt')).filter(dt__lt=afternoon_min_dt),
+                [morning_min_dt],
+                transform=lambda d: d.dt)
+        self.assertQuerysetEqual(
+                Session.objects.annotate(dt=Min('events__dt')).filter(dt__gte=afternoon_min_dt),
+                [afternoon_min_dt],
+                transform=lambda d: d.dt)
+
     def test_query_dates(self):
         Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0))
         Event.objects.create(dt=datetime.datetime(2011, 1, 1, 4, 30, 0))
@@ -412,6 +434,28 @@ class NewDatabaseTests(BaseDateTimeTests):
             'dt__max': datetime.datetime(2011, 9, 1, 23, 20, 20, tzinfo=EAT),
         })
 
+    def test_query_annotation(self):
+        # Only min and max make sense for datetimes.
+        morning = Session.objects.create(name='morning')
+        afternoon = Session.objects.create(name='afternoon')
+        SessionEvent.objects.create(dt=datetime.datetime(2011, 9, 1, 23, 20, 20, tzinfo=EAT), session=afternoon)
+        SessionEvent.objects.create(dt=datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT), session=afternoon)
+        SessionEvent.objects.create(dt=datetime.datetime(2011, 9, 1, 3, 20, 40, tzinfo=EAT), session=morning)
+        morning_min_dt = datetime.datetime(2011, 9, 1, 3, 20, 40, tzinfo=EAT)
+        afternoon_min_dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)
+        self.assertQuerysetEqual(
+                Session.objects.annotate(dt=Min('events__dt')).order_by('dt'),
+                [morning_min_dt, afternoon_min_dt],
+                transform=lambda d: d.dt)
+        self.assertQuerysetEqual(
+                Session.objects.annotate(dt=Min('events__dt')).filter(dt__lt=afternoon_min_dt),
+                [morning_min_dt],
+                transform=lambda d: d.dt)
+        self.assertQuerysetEqual(
+                Session.objects.annotate(dt=Min('events__dt')).filter(dt__gte=afternoon_min_dt),
+                [afternoon_min_dt],
+                transform=lambda d: d.dt)
+
     def test_query_dates(self):
         # Same comment as in test_query_date_related_filters.
         Event.objects.create(dt=datetime.datetime(2011, 1, 1, 1, 30, 0, tzinfo=EAT))
