# SQL date filter

**URL:** <https://clarionhub.com/t/sql-date-filter/7606>\
**Category:** questions\
**Tags:** sql\
**Created:** [October 25, 2024, 7:38pm UTC](https://clarionhub.com/t/sql-date-filter/7606 "2024-10-25T19:38:24Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![JonW](https://clarionhub.com/user_avatar/clarionhub.com/jonw/32/1344_2.png) [@JonW](https://clarionhub.com/u/JonW)\
**Post date:** [October 31, 2024, 12:11pm UTC](https://clarionhub.com/t/sql-date-filter/7606/21 "2024-10-31T12:11:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JonW](https://clarionhub.com/user_avatar/clarionhub.com/jonw/32/1344_2.png) [@JonW](https://clarionhub.com/u/JonW)\
**Post date:** [October 31, 2024, 1:42pm UTC](https://clarionhub.com/t/sql-date-filter/7606/22 "2024-10-31T13:42:18Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![totalhip](https://clarionhub.com/user_avatar/clarionhub.com/totalhip/32/1477_2.png) [@totalhip](https://clarionhub.com/u/totalhip)\
**Post date:** [October 31, 2024, 2:19pm UTC](https://clarionhub.com/t/sql-date-filter/7606/23 "2024-10-31T14:19:28Z")

</div>

> [@JonW](#):
>
> It’s a bit of a mess of parentheses and quotes, but it works.

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.

[Previous page](https://clarionhub.com/t/sql-date-filter/7606.md?page=1)
