On 1 jun, 16:18, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > Can you try replace: > > return "DATEPART('%s' FROM %s)" % (what, self.expand(field)) > > with > > return "DATEPART(%s, %s)" % (what, self.expand(field)) >
I tried from the console, this work fine. SQL: select * FROM my_table WHERE DATEPART(year, my_table.my_datetime_field) = 2011; so your suggestion [1] should work. Jose [1] return "DATEPART(%s, %s)" % (what, self.expand(field))