SQL date filter

Just an Oracle thing I guess. You can say it’s a date by date’whatever’ and it will expect it in ISO format, but if you just give it a string that is supposed to go in a date column, or be compared to a date, it will try to read it in whatever the NLS (national language setting) format is in force, and give up if it fails.

Here’s what actually works – I started off with a fixed SQL() string in the browse’s filter and followed on from there…

You are selecting your date limit in a dropdown. In the event accepted for that, you put:

BRW1.SetFilter('(SQL(trunc(DT) = date''' & date_string & '''))')
brw1.applyfilter()
brw1.resetsort(1)

It’s a bit of a mess of parentheses and quotes, but it works.

1 Like

For this reason, I use equates and functions such as:
eSpace EQUATE(‘<32>’)
eSQuote EQUATE(‘<39>’)
SQuote FUNCTION - return passed string with single quotes
Enclose FUNCTION - return passed string enclosed with ()

Makes the code for SQL filters much easier to read & debug.