Bug fix for date comparison issue