The function requires two arguments, a string with format descriptor(s) and a decimal numeric value to be formatted.
The descriptor is a string where %i represents the integer part of the number and %f represents the fractional part of the number. Format specifiers may be given in any order and as many times as desired.
%i and %f can be follewed by a length specifier. This is a positive integer number that specifies how many characters the formatted string for that part will be. If necessary it will will be padded with leading zero's (“0”).
The fractional part of the number is automatically rounded so its length will not exceed the specified length.
If no length specifier is given or if a part of the numeric value is bigger than can fit in the specified number of characters, the full given value will be returned. Any other characters in the format string will be copied to the result as they are.
FORMAT('%i2%f2', '10.25') => "1025" FORMAT('%i2:%f2', '10.05') => "10:05" FORMAT('%i2,%f2', '10.249999') => "10,25" FORMAT('%i2,%f', '10.249999') => "10,249999" FORMAT('%i3', '10.25') => "010" FORMAT('%f4', '10.25') => "0025" FORMAT('%i2', 100) => "100" FORMAT('%i', 10.25) => "10" FORMAT('The fraction is %f and the integer part is %i', 10.25) => "The fraction is 25 and the integer part is 10"