'Converts the query into a date extraction query.'

def add_date_select(self, field_name, lookup_type, order='ASC'):

    try:
        result = self.setup_joins(field_name.split(LOOKUP_SEP), self.get_meta(), self.get_initial_alias(), False)
    except FieldError:
        raise FieldDoesNotExist(("%s    has    no    field    named    '%s'" % (self.model._meta.object_name, field_name)))
    field = result[0]
    assert isinstance(field, DateField), ("%r    isn't    a    DateField." % field.name)
    alias = result[3][(-1)]
    select = Date((alias, field.column), lookup_type)
    self.select = [select]
    self.select_fields = [None]
    self.select_related = False
    self.set_extra_mask([])
    self.distinct = True
    self.order_by = (((order == 'ASC') and [1]) or [(-1)])
    if field.null:
        self.add_filter((('%s__isnull' % field_name), False))
