- Salesforce Development Posts by Matt Lacey

Displaying Number Fields as Integers on Visualforce Pages

Posted 2010-09-09

It always bugs me that when displaying number fields on a Visualforce page it's rendered as a decimal, I know all numbers in the database are decimal, and I know why they use that even if you choose zero decimal places for the field, but it's still irksome. Often I've used classes which mimic the object and used field__c.intValue() to assign the value to an integer member of the class, then displayed that class. This is a bit of a pain and also excessive and it finally occurred to me to check what functions are available in Visualforce pages for manipulating the merge fields.

Lo and behold, there is a FLOOR() function! Really should have guessed this sooner, but there you go. So to display a nice integer on the page simply do:


Job done.