Hi
This is using MS SQLServer 2000.
qry = (db.my_table.my_datetime_field.year()==2011)
rows = db(qry).select()
This fails.
db._lastsql output is equivalent to:
SELECT * FROM my_table WHERE (DATEPART('year' FROM
my_table.my_datetime_field) = 2011);
The following works fine:
SELECT * FROM my_table WHERE year(my_table.my_datetime_field) = 2011;
in dal.py
class MSSQLAdapter(BaseAdapter):
replace
def EXTRACT(self,field,what):
return "DATEPART('%s' FROM %s)" % (what, self.expand(field))
with:
def EXTRACT(self,field,what):
return "%s(%s)" % (what, self.expand(field))
Again, this is with MS SQLServer 2000, I do not know if other versions
will do the same.
Jose