# search problem

**URL:** <https://forum.servoy.com/t/search-problem/7661>\
**Category:** Classic Servoy\
**Created:** [June 13, 2007, 8:44am UTC](https://forum.servoy.com/t/search-problem/7661 "2007-06-13T08:44:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![subhranild](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@subhranild](https://forum.servoy.com/u/subhranild)\
**Post date:** [June 13, 2007, 8:44am UTC](https://forum.servoy.com/t/search-problem/7661/1 "2007-06-13T08:44:43Z")

</div>

I have a problem with search.  
I want to serch data on a field like tbl\_fld1 and condition is

> tbl\_fld1 != 0

I write a method and attached with onShow event  
my code is

> controller.find() ;  
> tbl\_fld1 != 0  
> controller.search();

It shows all records and unable to search.  
But through menu if I put != 0 at tbl\_fld1 then it is working.

---

<div class="post-metadata">

**Author:** ![rodneysieb](https://avatars.discourse-cdn.com/v4/letter/r/87869e/32.png) [@rodneysieb](https://forum.servoy.com/u/rodneysieb)\
**Post date:** [June 13, 2007, 8:50am UTC](https://forum.servoy.com/t/search-problem/7661/2 "2007-06-13T08:50:24Z")

</div>

Hi

Try using

controller.find() ;  
tbl\_fld1 = “!=0”  
controller.search();

i think will be ok

---

<div class="post-metadata">

**Author:** ![subhranild](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@subhranild](https://forum.servoy.com/u/subhranild)\
**Post date:** [June 13, 2007, 8:59am UTC](https://forum.servoy.com/t/search-problem/7661/3 "2007-06-13T08:59:23Z")

</div>

Thanks Rodney.  
Its working.  
But I do that another way

> controller.find()  
> tbl\_fld1 = 0;  
> controller.search();  
> controller.invertRecords();

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [June 13, 2007, 4:13pm UTC](https://forum.servoy.com/t/search-problem/7661/4 "2007-06-13T16:13:04Z")

</div>

> subhranild:  
> Thanks Rodney.  
> Its working.  
> But I do that another way
> 
> > controller.find()  
> > tbl\_fld1 = 0;  
> > controller.search();  
> > controller.invertRecords();

Doing this you are firing 2 queries when only 1 is enough.  
Take a look at the manuals, they are really well done. Online help is a good resource too.

---

<div class="post-metadata">

**Author:** ![subhranild](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@subhranild](https://forum.servoy.com/u/subhranild)\
**Post date:** [June 15, 2007, 1:19pm UTC](https://forum.servoy.com/t/search-problem/7661/5 "2007-06-15T13:19:07Z")

</div>

I face a new problem to search.  
please any one help me.  
I want search between two dates and two dates will be taken in two global field and search will on between two globals.

---

<div class="post-metadata">

**Author:** ![grahamg](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@grahamg](https://forum.servoy.com/u/grahamg)\
**Post date:** [June 15, 2007, 1:39pm UTC](https://forum.servoy.com/t/search-problem/7661/6 "2007-06-15T13:39:45Z")

</div>

> I want search between two dates and two dates will be taken in two global field and search will on between two globals.

Try this to get you started:

```auto
var startdate = globals.ctf_CreatedDate
startdate.setHours(00)
startdate.setMinutes(00)
startdate.setSeconds(00)
var thestart = utils.dateFormat(startdate, 'MM-dd-yyyy HH:mm:ss')

var enddate = new Date()
enddate.setHours(23)
enddate.setMinutes(59)
enddate.setSeconds(59)
var theend = utils.dateFormat(enddate, 'MM-dd-yyyy HH:mm:ss') 

controller.find()
createddate = thestart + '...' + theend+ '|MM-dd-yyyy HH:mm:ss';
controller.search();

```

Regards

Graham Greensall  
Worxinfo Ltd

---

<div class="post-metadata">

**Author:** ![sanneke](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@sanneke](https://forum.servoy.com/u/sanneke)\
**Post date:** [June 15, 2007, 1:48pm UTC](https://forum.servoy.com/t/search-problem/7661/7 "2007-06-15T13:48:29Z")

</div>

```auto
var d1 = globals.start_date
d1.setHours(00)
d1.setMinutes(00)
d1.setSeconds(00)
var df1 = utils.dateFormat(d1, 'MM-dd-yyyy hh:mm:ss') 

var d2 = globals.end_date
d2.setHours(23)
d2.setMinutes(59)
d2.setSeconds(59)
var df2 = utils.dateFormat(d2, 'MM-dd-yyyy hh:mm:ss')

controller.find()
dateentered = df1+'...' + df2+'|MM-dd-yyyy hh:mm:ss' 
controller.search()

```

This should help you. You can search between dates using the …

---

<div class="post-metadata">

**Author:** ![subhranild](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@subhranild](https://forum.servoy.com/u/subhranild)\
**Post date:** [June 15, 2007, 1:53pm UTC](https://forum.servoy.com/t/search-problem/7661/8 "2007-06-15T13:53:29Z")

</div>

Thanks to Graham and sanneke.  
Both of ur code working nicely.  
Thanke once again.

---

<div class="post-metadata">

**Author:** ![ars](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@ars](https://forum.servoy.com/u/ars)\
**Post date:** [June 29, 2007, 1:10pm UTC](https://forum.servoy.com/t/search-problem/7661/9 "2007-06-29T13:10:08Z")

</div>

Oh,  
thats great
