filter query results by distinct, added dayfirst in parsing datetime values