diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index a9b1aa3..8ddb736 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -63,13 +63,17 @@ class DatabaseFeatures(BaseDatabaseFeatures):
 class DatabaseOperations(BaseDatabaseOperations):
     def date_extract_sql(self, lookup_type, field_name):
         # sqlite doesn't support extract, so we fake it with the user-defined
-        # function django_extract that's registered in connect().
-        return 'django_extract("%s", %s)' % (lookup_type.lower(), field_name)
+        # function django_extract that's registered in connect(). Note that
+        # single quotes are used because this is a string (and could otherwise
+        # cause a collision with a field name).
+        return "django_extract('%s', %s)" % (lookup_type.lower(), field_name)
 
     def date_trunc_sql(self, lookup_type, field_name):
         # sqlite doesn't support DATE_TRUNC, so we fake it with a user-defined
-        # function django_date_trunc that's registered in connect().
-        return 'django_date_trunc("%s", %s)' % (lookup_type.lower(), field_name)
+        # function django_date_trunc that's registered in connect(). Note that
+        # single quotes are used because this is a string (and could otherwise
+        # cause a collision with a field name).
+        return "django_date_trunc('%s', %s)" % (lookup_type.lower(), field_name)
 
     def drop_foreignkey_sql(self):
         return ""
diff --git a/tests/regressiontests/backends/models.py b/tests/regressiontests/backends/models.py
index 61b7b1a..423bead 100644
--- a/tests/regressiontests/backends/models.py
+++ b/tests/regressiontests/backends/models.py
@@ -15,6 +15,11 @@ class Person(models.Model):
     def __unicode__(self):
         return u'%s %s' % (self.first_name, self.last_name)
 
+class SchoolClass(models.Model):
+    year = models.PositiveIntegerField()
+    day = models.CharField(max_length=9, blank=True)
+    last_updated = models.DateTimeField()
+
 qn = connection.ops.quote_name
 
 __test__ = {'API_TESTS': """
diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py
index e4fa824..7b1fcb9 100644
--- a/tests/regressiontests/backends/tests.py
+++ b/tests/regressiontests/backends/tests.py
@@ -1,9 +1,12 @@
 # -*- coding: utf-8 -*-
 # Unit and doctests for specific database backends.
+import datetime
+import models
 import unittest
 from django.db import backend, connection, DEFAULT_DB_ALIAS
 from django.db.backends.signals import connection_created
 from django.conf import settings
+from django.test import TestCase
 
 class Callproc(unittest.TestCase):
 
@@ -33,6 +36,39 @@ class LongString(unittest.TestCase):
             row = c.fetchone()
             c.execute('DROP TABLE ltext')
             self.assertEquals(long_str, row[0].read())
+            
+class SqliteTest(TestCase):
+
+    def test_django_date_trunc(self):
+        """
+        Test the custom ``django_date_trunc method``, in particular against
+        fields which clash with strings passed to it (e.g. 'year') - see
+        #12818__.
+
+        __: http://code.djangoproject.com/ticket/12818
+
+        """
+        if settings.DATABASE_ENGINE != 'sqlite3':
+            return
+        updated = datetime.datetime(2010, 2, 20)
+        models.SchoolClass.objects.create(year=2009, last_updated=updated)
+        years = models.SchoolClass.objects.dates('last_updated', 'year')
+        self.assertEqual(list(years), [datetime.datetime(2010, 1, 1, 0, 0)])    
+
+    def test_django_extract(self):
+        """
+        Test the custom ``django_extract method``, in particular against fields
+        which clash with strings passed to it (e.g. 'day') - see #12818__.
+
+        __: http://code.djangoproject.com/ticket/12818
+
+        """
+        if settings.DATABASE_ENGINE != 'sqlite3':
+            return
+        updated = datetime.datetime(2010, 2, 20)
+        models.SchoolClass.objects.create(year=2009, last_updated=updated)
+        classes = models.SchoolClass.objects.filter(last_updated__day=20)
+        self.assertEqual(len(classes), 1)
 
 def connection_created_test(sender, **kwargs):
     print 'connection_created signal'
