I am trying to truncate a datetime field to a date and afterwards use that filed for aggregation operations. I managed to that with date_trunc_sql function like this: truncate_date = con
inner_query = "mytable.datetime AT TIME ZONE '%s'" % 'Europe/Amsterdam'
truncate_date = conection.ops.date_trunc_sql('day', inner_query)
queryset = queryset.extra({'day': truncate_date})
Now i saw that there is also a function datetime_trunc_sql that takes the timeozone as paramater but could not make that work. I tried:
truncate_date = conection.ops.datetime_trunc_sql('day','mytable.datetime','Europe/Amsterdam')
queryset = queryset.extra({'day': truncate_date})
It fails with the error StopIteration at api/v3/...
and closes the connection at the second line: queryset = queryset.extra({'day': truncate_date})
Any ideas why?
Thanks