How can I format a numeric field to show blanks if it contains a zero?
Thanks
How can I format a numeric field to show blanks if it contains a zero?
Thanks
use # - (zero shows as absent)
Thanks! I would try that.
Hi Jan,
This does not work completely.
I have a value 0 in a number field. I just # as format. But it shows the 0 instead of blank
Thanks
Hameed
Also when I clear the number field, it puts a zero by default. But I have not set any default value. How to overcome that please.
Thanks
It seems a bug from SUN, in the docs they say # - show 0 as absent
http://java.sun.com/j2se/1.4.2/docs/api … ormat.html
but it does not show, we will report this to SUN.
BTW it seems sort of working (zero not shown) when “#.00” is used as format
Actually the docs are probably a bit lousy, but this is really expected behavior. The # means blank padding, that is, “###” with the number 3 for example is shown as " 3". However, it will always output a number (and never a total blank), so “###” with the number 0 becomes " 0".
The comment from the SUN source code is clearer than the JavaDoc:
// Handle patterns with no ‘0’ pattern character. These patterns
// are legal, but must be interpreted. “##.###” → “#0.###”.
// “.###” → “.0##”.
/* We allow patterns of the form “####” to produce a zeroDigitCount of
Thus this behavior is intentional.
I’m afraid you’re going to have to find a different way of displaying an empty string for the number zero… (maybe using a calculation).
Last post on this subject was 2005.
Now it is 2012 and Servoy 5.2 / 6.0
Is there already a solution for this situation?
I have a column in the database numeric(9, 4)
Default format is #,##0.00##
So it shows:
DB Value Format
5,0000 5,00
5,2500 5,25
5,2570 5,257
But in case of value 0, I would like to see an empty field (so blank when zero).
Otherwise I must allow NULL values in the database and let 0 be a NULL value, but that is not really what I prefer.
this is just how the formatting works
and if you have a 0 then you have a 0, that is really not the same a null (which is nothing)
if you want something else, what you can do is place a converter in between, so that 0 are converted to null and visa versa i guess