I have a set of records in a table, with some records having invalid date. I wanted to ignore those invalid records and do a check with rest of the records. I framed a query like below but I don't find it working.
select * from tbl_name i
where is_date(i.dob) and i.dob::date > CURRENT_DATE;
I got to know that sql doesn't short circuit so it also consider invalid record and end up in date/time out of range. Please help me alter this query in a way i could eliminate invalid dates and do date comparison on valid dates only.
is_date()function in Postgres, so you must have written that yourself. Without seeing the source of that function it's impossible to tell what's going on. But if the column had been correctly defined asdatethis wouldn't be needed to begin with. The correct solution to the problem is to change the column to thedatetype