This is a simple question, but I can’t figure out how to do it at the moment.
I have a date field in a search query. The request is not dynamic, or it would be easier. I need to return records that correspond to the entered date or if the date is not specified, then it should return everything.
This is what I have, but it does not work. It does not return any rows when there are criteria or when there are none.
AND ( (table.dateField = p_dateField)
OR (table.dateField = table.dateField and table.dateField is null))
early.
After an hour of working with this, I came up with this:
and (
( p_dateField IS NOT NULL AND table.dateField = p_dateField)
OR ( p_dateField IS NULL AND (table.dateField is null or (table.dateField is not null))
)
It works for several tests that I was able to run against it. If someone can suggest a better method, please do.
Thank!
source
share