fix laterthan, Redmine #6530

(cherry picked from commit 0e6538d66e6dc0ab8d2102042532044aca0fd2f0)