Dr. Evil Posted March 6, 2010 Posted March 6, 2010 How can fix the below calculation to round the result to a two decimal number? For example: 02:00:00 x $80.20 = $160.40, NOT $160.412457457 (I know the numbers are not accurate, just for sake of example) My current calculation: n_rate_hourly * (Hour(t_time) + (Minute(t_time)/60) Thank you for your help!
Peter (duksis3) Posted March 6, 2010 Posted March 6, 2010 You really need result 160.40? Not 160.41? - a I see on example. What in this case - 160.46 also need to be 160.40? Rate calculations are very different and not always use "Round". Sometimes also function Truncate is used.
TheTominator Posted March 6, 2010 Posted March 6, 2010 Most commonly changing the settings on the layout for the number display is the way to go. I presume you actually need the number rounded to the nearest penny and the dollar sign added so that you can display the info in a UI element such as a dialog or export the value already formatted. In that case you need to handle adding a trailing zero so that your answer is $160.40 instead of 160.4. Handling a dollar sign and potentially a negative sign is also needed when formatting it as text. For a numeric field called "Amount", the following may be the solution you seek. To get this behavior: 160.08256 --> $160.08 160.1 --> $160.10 -160.05665 --> -$160.06 .205 --> $0.21 Use this function: Case( Amount < 0; "-"; "" ) & Let ( [ amt = Round ( Abs(Amount) ; 2 ); dollars = Int(amt); cents = 100 * (amt - dollars) ]; "$" & dollars & SerialIncrement ( ".00" ; cents ) )
Recommended Posts
This topic is 5409 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now