removed datetosy function from JOINs, added to base tables