# Date field in find mode

**URL:** <https://forum.servoy.com/t/date-field-in-find-mode/16917>\
**Category:** Classic Servoy\
**Created:** [January 9, 2013, 8:15pm UTC](https://forum.servoy.com/t/date-field-in-find-mode/16917 "2013-01-09T20:15:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JuanMartin](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@JuanMartin](https://forum.servoy.com/u/JuanMartin)\
**Post date:** [January 9, 2013, 8:15pm UTC](https://forum.servoy.com/t/date-field-in-find-mode/16917/1 "2013-01-09T20:15:03Z")

</div>

Hello

In the date field I use the mask ‘dd-MM-yyyy|mask’ so that the user does not have to type ‘-’ between date and month and year.

The problem is in find mode this mask not work, and the search is not correct

Any idea?

Thanks

Servoy 6.1.3

---

<div class="post-metadata">

**Author:** ![Mark\_Crichton](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@Mark\_Crichton](https://forum.servoy.com/u/Mark_Crichton)\
**Post date:** [January 30, 2013, 8:31am UTC](https://forum.servoy.com/t/date-field-in-find-mode/16917/2 "2013-01-30T08:31:46Z")

</div>

Hello Juan

Although the below filter is syntax is deprecated it may help you. This syntax filters between two dates  
The # ignores the minutes and seconds  
variable vFromDate is form variable usually selected form date picker, but is in similar format.

if(controller.find() ) {  
hedstart = ‘#’ + utils.dateFormat(vFromDate,‘dd-MM-yyyy’) + ’ … ’ + utils.dateFormat(vToDate,‘dd-MM-yyyy’ ) + ‘|dd-MM-yyyy’  
controller.search()

---

<div class="post-metadata">

**Author:** ![studiomiazzo](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@studiomiazzo](https://forum.servoy.com/u/studiomiazzo)\
**Post date:** [March 26, 2013, 2:16pm UTC](https://forum.servoy.com/t/date-field-in-find-mode/16917/3 "2013-03-26T14:16:10Z")

</div>

Hi,

I too tried the solution you provide but with no luck. Is there any alternative method to specify a date range when performing a find on a foundset? I’m really starting to despair of doing this!

---

<div class="post-metadata">

**Author:** ![chaitanyas](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@chaitanyas](https://forum.servoy.com/u/chaitanyas)\
**Post date:** [April 1, 2013, 8:18am UTC](https://forum.servoy.com/t/date-field-in-find-mode/16917/4 "2013-04-01T08:18:22Z")

</div>

Hi ,

In the find mode we can give condition for search for date field , like this ,

if(fs.find()) {

data\_field = v\_user\_enter\_date (or) v\_date\_picker + ‘|ddMMyyyy’ ;

fs.search()  
}

Hope this will helpful to you . Use this for testing user entry is a valid date ,  
(/^\d{1,2}\d{1,2}\d{4}...\d{1,2}\d{1,2}\d{4}$/.test( v\_user\_enter\_date) && (utils.stringPatternCount( v\_user\_enter\_date, ‘.’)==3) )|| (/^\d{1,2}\d{1,2}\d{4}$/.test( v\_user\_enter\_date))

Thanks  
Chaitanya s

---

<div class="post-metadata">

**Author:** ![kurtbleicken](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@kurtbleicken](https://forum.servoy.com/u/kurtbleicken)\
**Post date:** [April 2, 2013, 1:36pm UTC](https://forum.servoy.com/t/date-field-in-find-mode/16917/5 "2013-04-02T13:36:47Z")

</div>

Might try converting the date to a number, like 20130402. Then using those to do your search.

---

<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:** [April 11, 2013, 10:21am UTC](https://forum.servoy.com/t/date-field-in-find-mode/16917/6 "2013-04-11T10:21:18Z")

</div>

> Mark Crichton:  
> Hello Juan
> 
> Although the below filter is syntax is deprecated it may help you. This syntax filters between two dates  
> The # ignores the minutes and seconds  
> variable vFromDate is form variable usually selected form date picker, but is in similar format.
> 
> if(controller.find() ) {  
> hedstart = ‘#’ + utils.dateFormat(vFromDate,‘dd-MM-yyyy’) + ’ … ’ + utils.dateFormat(vToDate,‘dd-MM-yyyy’ ) + ‘|dd-MM-yyyy’  
> controller.search()

Hi Juan

I have tested the above code and it works fine. I believe you might be missing something so I have attached a sample solution. You can import it with sample data to check.

Hope this helps.

Regards  
Lopamudra  
[http://www.mindfiresolutions.com/](http://www.mindfiresolutions.com/)

[filterByDate.servoy](https://forum.servoy.com/uploads/short-url/y89oGqUncLzbbq6e0p8jBDg5yaq.servoy) (5.25 KB)
