Sue

Taking heed of the fact that Jason's function also deals with negative amounts I have amended my formulae as follows:

"$"& Int (currentpayfield) & "." & Left (100 * Round( Abs (currentpayfield) - Int (currentpayfield) * Sign (currentpayfield) ; 2) & "00" ; 2)

or (Custom function):

FormatAsDollars ( Amount )

Let ([ dollars = Int (Amount) ;
       cents = Round (Abs (Amount ) - dollars * Sign ( dollars ) ; 2) ;
       centsAsText = Left (100 * cents & "00" ; 2)
      ] ;
      "$" & dollars & "." & centsAsText
     )

Noting Beverly's point, if the precision is variable, add a 2nd parameter to the CF:

FormatAsDollars ( Amount ; Precision)

Let ([ dollars = Int (Amount) ;
cents = Round (Abs (Amount ) - dollars * Sign ( dollars ) ; Precision) ; centsAsText = Left (10 ^ precision * cents & "000000000000000" ; Precision)
      ] ;
      "$" & dollars & "." & centsAsText
     )

with enough zeros in the centsAsText line to allow for your maximum precision requirement

cheers

Tom

Reply via email to