Search number with decimal point

I’ve noticed when searching on fields of datatype number with foundset.find() and foundset.search() Servoy loses the decimal point…

I have tried :

_a = 10 / 4

  1. _fs.number_field = ‘>=’ + _a
  2. _fs.number_field = ‘>=’ + _a + ‘|00000.00’
  3. _fs.number_field = ‘>=’ + _a + ‘|00000,00’

In all cases when I look at : databaseManager.getSQLParameters(_fs)
I see the value : 25.0 in stead of 2.5

Have I missed something ? I cannot find anything in Wiki or on forum…

Servoy 5.2.8

Regards,

I noticed this too when the locale is set to Nederlands.
If I set it to English (us) there is no issue.
I guess it has to do with decimal point that is not interpreted…

Regards,

Thanks Hans,

But then option 3) should work…
I think format (|…) is not supported with number fields ?

Please comment, Servoy

I tried using ```
'=> ’ + _a.toLocaleString()


B.t.w. this is the same for 5.2.7 and 5.2.8

You mean '>= ’ + _a.toLocaleString() ?

I noticed that

_fs.number_field = '>=' + _utils.numberFormat(_a, '#,###.00')

Does use the locale settings and the your code works !

If you display the value of ‘>=’ + _utils.numberFormat(_a, ‘#,###.00’) it is => 2,50 when the locale is Netherlands

Ok, thanks. I was just on my way to test the utils.numberFormat() !

Regards,

Could one of the Servoyans comment on this ?

numberFormat() is exactly what you need to do, there is currently no other solution for this.

If you set something through scripting then you have to set it the same way as a user would do it in a textfield.

So yes a dutch guy would type: 10,09 and a guys from the usa: 10.09

So you must make sure if you do in find:

dataprovider = “>=” + number

that that number is formatted the way the locale expects it to be.

This is important enough for the wiki, isn’t it?

Will make sure it gets added in the appropriate locations.

Paul

Okay, thanks!