      >>> from django.db.models.functions import Extract
      >>> start = datetime(2015, 6, 15)
      >>> end = datetime(2015, 7, 2)
      >>> Experiment.objects.create(
      ...    start_time=start, start_date=start.date(),
      ...    end_time=end, end_date=end.date())
      >>> # Add the experiment start year as a field in the QuerySet.
      >>> experiment = Experiment.objects.annotate(
      ...    start_year=Extract('start_time', 'year')).get()
      >>> experiment.start_year
      2015
 
</s> remove     ...    start_year=Extract('start_time', 'year')).get()
 </s> add     ...    start_year=Extract('start_datetime', 'year')).get() </s> remove     ...    start_time__year=Extract('end_time', 'year')).count()
 </s> add     ...    start_datetime__year=Extract('end_datetime', 'year')).count() </s> remove     >>> Experiment.objects.create(start_time=start1, start_date=start1.date())
    >>> Experiment.objects.create(start_time=start2, start_date=start2.date())
    >>> Experiment.objects.create(start_time=start3, start_date=start3.date())
 </s> add     >>> Experiment.objects.create(start_datetime=start1, start_date=start1.date())
    >>> Experiment.objects.create(start_datetime=start2, start_date=start2.date())
    >>> Experiment.objects.create(start_datetime=start3, start_date=start3.date()) </s> remove     ...    start_time=start_2015, start_date=start_2015.date(),
    ...    end_time=end_2015, end_date=end_2015.date())
 </s> add     ...    start_datetime=start_2015, start_date=start_2015.date(),
    ...    end_datetime=end_2015, end_date=end_2015.date()) </s> remove     ...    start_time=start_2015, start_date=start_2015.date(),
    ...    end_time=end_2015, end_date=end_2015.date())
 </s> add     ...    start_datetime=start_2015, start_date=start_2015.date(),
    ...    end_datetime=end_2015, end_date=end_2015.date())
    ...    start_datetime=start, start_date=start.date(),
    ...    end_datetime=end, end_date=end.date())
      >>> from django.db.models.functions import Extract
      >>> start = datetime(2015, 6, 15)
      >>> end = datetime(2015, 7, 2)
      >>> Experiment.objects.create(
    ...    start_datetime=start, start_date=start.date(),
    ...    end_datetime=end, end_date=end.date())
    ...    start_datetime=start, start_date=start.date(),
    ...    end_datetime=end, end_date=end.date())
      >>> # Add the experiment start year as a field in the QuerySet.
      >>> experiment = Experiment.objects.annotate(
      ...    start_year=Extract('start_time', 'year')).get()
      >>> experiment.start_year
      2015
keep keep keep keep replace replace keep keep keep keep keep
 Refs #25774 -- Adjusted datetime database function docs field names. 
docs/ref/models/database-functions.txt