# foundsetFilter and Date

**URL:** <https://forum.servoy.com/t/foundsetfilter-and-date/12851>\
**Category:** Classic Servoy\
**Created:** [September 11, 2010, 11:11am UTC](https://forum.servoy.com/t/foundsetfilter-and-date/12851 "2010-09-11T11:11:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ffow](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@ffow](https://forum.servoy.com/u/ffow)\
**Post date:** [September 11, 2010, 11:11am UTC](https://forum.servoy.com/t/foundsetfilter-and-date/12851/1 "2010-09-11T11:11:56Z")

</div>

Any suggestions as to what I’m doing wrong as I want to filter the foundset based on a date, the result is always empty (no data):

```auto
valueDateArg = '#' + utils.dateFormat(valueDateArg,'yyyy/MM/dd') + '|yyyy/MM/dd'
var success = forms.frm_lst_route_messages.foundset.addFoundSetFilterParam('value_date','=',valueDateArg, 'routeFilterDate')
forms.frm_lst_route_messages.foundset.loadAllRecords()

```

---

<div class="post-metadata">

**Author:** ![lwjwillemsen](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lwjwillemsen/32/4987_2.png) [@lwjwillemsen](https://forum.servoy.com/u/lwjwillemsen)\
**Post date:** [September 12, 2010, 10:59am UTC](https://forum.servoy.com/t/foundsetfilter-and-date/12851/2 "2010-09-12T10:59:36Z")

</div>

Hi,

if value\_date is a datetime field then you are querying now for only the 00:00:00 time of that date…

Welcome to the (sql) datetime world…

Most of the sql server vendors have their own date and datetime functions dialect.

My advice : stay as much as possible to Servoy datetime searching and if not possible to ANSI sql.

Regards,

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [September 13, 2010, 11:51am UTC](https://forum.servoy.com/t/foundsetfilter-and-date/12851/3 "2010-09-13T11:51:36Z")

</div>

ffow,

The hash (#) for date searches is only support in find/search, not in table filter.  
(Noet thar the hash as case-insentive search is supported in filters).

You can use the between operators to find all messages of the day.  
The object arguments needs to be an array of 2 date objects:

```auto
forms.frm_lst_route_messages.foundset.addFoundSetFilterParam('value_date','between',[date1, date2], 'routeFilterDate')

```

Rob

---

<div class="post-metadata">

**Author:** ![deezzub](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@deezzub](https://forum.servoy.com/u/deezzub)\
**Post date:** [May 19, 2014, 3:45pm UTC](https://forum.servoy.com/t/foundsetfilter-and-date/12851/4 "2014-05-19T15:45:40Z")

</div>

> rgansevles:
> 
> ```auto
> ...between',[date1, date2]...
> 
> ```

How can I do that, if date2 should be infinity future? I want to filter for records ‘\>=’ the current year.

---

<div class="post-metadata">

**Author:** ![lopamudram](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@lopamudram](https://forum.servoy.com/u/lopamudram)\
**Post date:** [May 21, 2014, 12:06pm UTC](https://forum.servoy.com/t/foundsetfilter-and-date/12851/5 "2014-05-21T12:06:44Z")

</div>

Hello deezzub,

To get the records ‘\>=’ current year:

```auto
var curDate = new Date(); // Get the new date object
curDate.setMonth(0,1); // Set the date to 1st Jan of the year
foundset.addFoundSetFilterParam('date_column_name', '>=', curDate);
foundset.loadAllRecords();

```

Hope this helps.

Lopamudra  
[lopamudram@mindfiresolutions.com](mailto:lopamudram@mindfiresolutions.com)

---

<div class="post-metadata">

**Author:** ![Bernd.N](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@Bernd.N](https://forum.servoy.com/u/Bernd.N)\
**Post date:** [June 21, 2014, 6:16am UTC](https://forum.servoy.com/t/foundsetfilter-and-date/12851/6 "2014-06-21T06:16:19Z")

</div>

Good idea, but be sure to set it really to 1st January at 00:00:00, setMonth() sets only the month, not the time.  
So you would miss the (small) time range up to the current time on 1st January.

You can try this here yourself with the -button:  
[http://www.w3schools.com/jsref/jsref\_setmonth.asp](http://www.w3schools.com/jsref/jsref_setmonth.asp)

var d = new Date();  
d.setMonth(0,1);  
d.setHours(0,0,0,0);
