# One more date range search problem

**URL:** <https://forum.servoy.com/t/one-more-date-range-search-problem/11769>\
**Category:** Classic Servoy\
**Created:** [February 12, 2010, 5:26pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769 "2010-02-12T17:26:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![nromeou](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@nromeou](https://forum.servoy.com/u/nromeou)\
**Post date:** [February 12, 2010, 5:26pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/1 "2010-02-12T17:26:54Z")

</div>

Hi,  
I apologize cause i know this has been asked many times but i just cant solve it.  
Im trying to use a find() on a date range, i clearly want all records whose date is between 2 other dates.  
heres my code

```auto
databaseManager.setAutoSave(true)
forms.pedidos.controller.find()

var Searchdate = new Date()
Searchdate = utils.dateFormat(globals.firstDate,'yyyy-MM-dd')+...+utils.dateFormat(globals.lastDate,'yyyy-MM-dd')

forms.pedidos.date = Searchdate +'| yyyy-MM-dd';

var found = forms.pedidos.controller.search()
databaseManager.setAutoSave(false)

```

And well its finding every record on the table.  
Any ideas??

Thanks in advance

---

<div class="post-metadata">

**Author:** ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.servoy.com/u/david)\
**Post date:** [February 12, 2010, 5:47pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/2 "2010-02-12T17:47:24Z")

</div>

Initialize the variable “Searchdate” as a string.

---

<div class="post-metadata">

**Author:** ![nromeou](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@nromeou](https://forum.servoy.com/u/nromeou)\
**Post date:** [February 12, 2010, 5:53pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/3 "2010-02-12T17:53:37Z")

</div>

still not working…

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 12, 2010, 6:13pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/4 "2010-02-12T18:13:59Z")

</div>

Try this:

```auto
if ( forms.pedidos.controller.find() ) {
    
    // 3 periods should be between quotes.
    var Searchdate = utils.dateFormat(globals.firstDate,'yyyy-MM-dd')+"..."+utils.dateFormat(globals.lastDate,'yyyy-MM-dd')
    
    // If I remember correctly when using a mask in search you need to use the hash sign at the beginning
    forms.pedidos.date = "#" + Searchdate +'| yyyy-MM-dd';
    
    var found = forms.pedidos.controller.search()
}

```

---

<div class="post-metadata">

**Author:** ![nromeou](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@nromeou](https://forum.servoy.com/u/nromeou)\
**Post date:** [February 12, 2010, 6:50pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/5 "2010-02-12T18:50:55Z")

</div>

Still finding all records…  
Im using servoy 5.0.0 and sybase central 11.0.1  
I also tryied without formatting the dates and i get the same results.

---

<div class="post-metadata">

**Author:** ![nromeou](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@nromeou](https://forum.servoy.com/u/nromeou)\
**Post date:** [February 12, 2010, 7:12pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/6 "2010-02-12T19:12:45Z")

</div>

could the quotes be affecting someting??  
i mean using " " or ’ ’ ?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 12, 2010, 7:15pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/7 "2010-02-12T19:15:17Z")

</div>

> nromeou:  
> could the quotes be affecting someting??  
> i mean using " " or ’ ’ ?

That shouldn’t make a difference.

Perhaps the extra space after the pipe character is the issue ?

---

<div class="post-metadata">

**Author:** ![nromeou](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@nromeou](https://forum.servoy.com/u/nromeou)\
**Post date:** [February 12, 2010, 7:38pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/8 "2010-02-12T19:38:23Z")

</div>

No… its not that ![:?]( "Confused")

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 12, 2010, 7:55pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/9 "2010-02-12T19:55:34Z")

</div>

I guess I have to really test this.  
What version of Servoy is this ?

---

<div class="post-metadata">

**Author:** ![nromeou](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@nromeou](https://forum.servoy.com/u/nromeou)\
**Post date:** [February 12, 2010, 8:16pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/10 "2010-02-12T20:16:39Z")

</div>

Servoy  
Version: 5.0.0 - build 859

The only thing that comes to my mind is that perhaps the format that the DB stores the date value is not the same im using to compare.  
What i dont get is that if i do a query on the DB it returns values with yyyy-MM-dd format but if i do an application.output of the date field it returns somenthing like Fri 23 Dec 00:00:0000 GMT 2009 (or something like that).

And what annoys me is that if i search for an exact date (not a range) it works perfectly fine.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 12, 2010, 8:34pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/11 "2010-02-12T20:34:24Z")

</div>

> nromeou:  
> if i do an application.output of the date field it returns somenthing like Fri 23 Dec 00:00:0000 GMT 2009 (or something like that).

When you do that you are actually looking at a Java Date object…so yes the formatting is different.  
But the locale/formatting shouldn’t make a difference. Let me do some testing.

---

<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:** [February 12, 2010, 8:47pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/12 "2010-02-12T20:47:24Z")

</div>

nromeou,

It is the extra space after pipe symbol, remove it and it will work

```auto
forms.pedidos.date = "#" + Searchdate +'|yyyy-MM-dd';

```

Rob

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 12, 2010, 9:09pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/13 "2010-02-12T21:09:20Z")

</div>

Yep, I tested it and like Rob said it’s the space.  
Also the # is required when you use a mask in your search (my memory didn’t fail me on this one).

---

<div class="post-metadata">

**Author:** ![nromeou](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@nromeou](https://forum.servoy.com/u/nromeou)\
**Post date:** [February 18, 2010, 3:22pm UTC](https://forum.servoy.com/t/one-more-date-range-search-problem/11769/14 "2010-02-18T15:22:00Z")

</div>

Thanks guys! ![:D]( "Very Happy")  
Seems that when i tryied that before i had something else wrong
