added datetime field template
fixed join_to_sql issue and where.from issue