fix generated sql from extract()