          sql, params = compiler.compile(self.lhs)
          lhs_output_field = self.lhs.output_field
          if isinstance(lhs_output_field, DateTimeField):
              tzname = self.get_tzname()
              sql, tz_params = connection.ops.datetime_extract_sql(self.lookup_name, sql, tzname)
              params.extend(tz_params)
          elif isinstance(lhs_output_field, DateField):
              sql = connection.ops.date_extract_sql(self.lookup_name, sql)
          elif isinstance(lhs_output_field, TimeField):
              sql = connection.ops.time_extract_sql(self.lookup_name, sql)
          else:
 
</s> remove             sql, params = connection.ops.datetime_trunc_sql(self.kind, inner_sql, tzname)
 </s> add             sql = connection.ops.datetime_trunc_sql(self.kind, inner_sql, tzname) </s> remove             params = []
 </s> add  </s> remove         sql, tz_params = connection.ops.datetime_cast_time_sql(lhs, tzname)
        lhs_params.extend(tz_params)
 </s> add         sql = connection.ops.datetime_cast_time_sql(lhs, tzname) </s> remove         sql, tz_params = connection.ops.datetime_cast_date_sql(lhs, tzname)
        lhs_params.extend(tz_params)
 </s> add         sql = connection.ops.datetime_cast_date_sql(lhs, tzname) </s> remove             params = []
 </s> add 
            sql = connection.ops.datetime_extract_sql(self.lookup_name, sql, tzname)
          sql, params = compiler.compile(self.lhs)
          lhs_output_field = self.lhs.output_field
          if isinstance(lhs_output_field, DateTimeField):
              tzname = self.get_tzname()
            sql = connection.ops.datetime_extract_sql(self.lookup_name, sql, tzname)
            sql = connection.ops.datetime_extract_sql(self.lookup_name, sql, tzname)
          elif isinstance(lhs_output_field, DateField):
              sql = connection.ops.date_extract_sql(self.lookup_name, sql)
          elif isinstance(lhs_output_field, TimeField):
              sql = connection.ops.time_extract_sql(self.lookup_name, sql)
          else:
keep keep keep keep replace replace keep keep keep keep keep
 Fixed #27802 -- Unified return value of db backend datetime SQL methods. 
django/db/models/functions/datetime.py