# Searching Problem with date

**URL:** https://forum.servoy.com/t/searching-problem-with-date/7824
**Category:** Classic Servoy
**Created:** [July 16, 2007, 7:45am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824 "2007-07-16T07:45:33Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![servoy\_help](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@servoy\_help](https://forum.servoy.com/u/servoy_help)
#### Post date: [July 16, 2007, 7:45am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/1 "2007-07-16T07:45:33Z")

</div>

Hi All,  
While searching records between two dates , I am getting an error.

Here is the code for searching used

controller.find();

date\_of\_post = formatToday + ’ 00:00:00…’ + formatLastDate + ’ 23:59:59|dd/MM/yyyy HH:mm:ss’;

controller.search();

Now While searching . it is trying to save data and when unable to save data it is giving the following error .

Setting dataprovider with name ‘date\_of\_award’ / type ‘DATETIME’ with value of wrong type 29/06/2007 00:00:00…05/07/2007 23:59:59|dd/MM/yyyy HH:mm:ss  
java.lang.IllegalArgumentException: Setting dataprovider with name ‘date\_of\_award’ / type ‘DATETIME’ with value of wrong type 29/06/2007 00:00:00…05/07/2007 23:59:59|dd/MM/yyyy HH:mm:ss

Please , let me know what is the error .

And , please suggest me is there any other way to search records within two given date range .  
This date is a table field .

Thanks in advance

---

<div class="post-metadata">

### Author: ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)
#### Post date: [July 16, 2007, 8:49am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/2 "2007-07-16T08:49:13Z")

</div>

Why does it complain about “date\_of\_award” when you in your code I only see “date\_of\_post”? Is there more code that would help us to find the problem?

---

<div class="post-metadata">

### Author: ![servoy\_help](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@servoy\_help](https://forum.servoy.com/u/servoy_help)
#### Post date: [July 16, 2007, 9:31am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/3 "2007-07-16T09:31:10Z")

</div>

Hi Patrick,  
It’s date\_of\_award instead of date\_of\_post.

controller.find();

date\_of\_award = formatToday + ’ 00:00:00…’ + formatLastDate + ’ 23:59:59|dd/MM/yyyy HH:mm:ss’;

controller.search();

---

<div class="post-metadata">

### Author: ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)
#### Post date: [July 16, 2007, 9:41am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/4 "2007-07-16T09:41:00Z")

</div>

Hmm. Then I think this should work. Are you sure you really are in find mode? How does it look like if you step into this using the debugger? Do you see that you are in find mode then?

---

<div class="post-metadata">

### Author: ![servoy\_help](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@servoy\_help](https://forum.servoy.com/u/servoy_help)
#### Post date: [July 16, 2007, 10:04am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/5 "2007-07-16T10:04:55Z")

</div>

using this code it is working . but some time it is trying to save data and  
error is coming  
I am searching records with combination of two fields  
please go through the following code that I am using

controller.find();

category = value .

// date field  
date\_of\_post = formatToday + ’ 00:00:00…’ + formatLastDate + ’ 23:59:59|dd/MM/yyyy HH:mm:ss’;

controller.search();

Sometime it works fine. But sometime it tries to save the record  
like the first search criteria

category value is changing (within search )

but while trying to save data ie … formatToday + ’ 00:00:00…’ + formatLastDate + ’ 23:59:59|dd/MM/yyyy HH:mm:ss’; to a date field it is giving error that I have already posted .

My objective is to filter data within two given date .

---

<div class="post-metadata">

### Author: ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)
#### Post date: [July 16, 2007, 10:15am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/6 "2007-07-16T10:15:57Z")

</div>

I don’t see anything wrong in your code. It just seems that in those occasions where you get the error, you are simply not in find mode. I can’t see when or how you call that method, but look out for that…

---

<div class="post-metadata">

### Author: ![servoy\_help](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@servoy\_help](https://forum.servoy.com/u/servoy_help)
#### Post date: [July 16, 2007, 10:25am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/7 "2007-07-16T10:25:18Z")

</div>

Thanks Patrick ,  
It is like in some cases control is coming out of find mode and tries to save data.

---

<div class="post-metadata">

### Author: ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)
#### Post date: [July 16, 2007, 11:01am UTC](https://forum.servoy.com/t/searching-problem-with-date/7824/8 "2007-07-16T11:01:25Z")

</div>

I spoke to Johan, about this and he adviced me to always check if you are in find-mode, because sometimes (when you use autoSave off, for example) a find, could fail.

so always do this:

```auto
if(controller.find() )
{
     //do your find stuff here
}

```
