db sort not working for postgres because it does not recover from invalid dates