[SOLVDED]Decimal places problem

arindamarindam Member Posts: 176
Hi all,

I am facing a problem with decimal round off.

The senario :
1. I have a feild which has the value say, 17.747462.
2. I want to return the value on 17.74. I was trying to use format function but not able to execute that properly.

N.B. I do not know the length of the number. But I want to take only 2 decimal places.

Please advice.
Thanks in Advance
Arindam

Comments

  • kinekine Member Posts: 12,562
    Result := ROUND(MyValue,0.01);
    

    And you can use third parameter to tell NAV how to round the value ('<' down - truncate the rest, '>' up - rond always up, '=' nearest - common rounding...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • sendohsendoh Member Posts: 207
    vRoundVal := (vValue,0.01,'='); 'nearest value
    Sendoh
    be smart before being a clever.
  • tihomirjurtihomirjur Member Posts: 21
    If you check the help file from Navision and type Format in help file you will see following:
    ...
    Using a standard format with an attribute:

    <Precision,2:3><Standard Format,0> will use Standard Format 0 and will format the data with a minimum of 2 and a maximum of 3 decimal places. See also the DecimalPlaces property. If you do not specify any precision the form will use the precision specified in the Decimal Places property of the corresponding field in the table.
    ...

    So if you want to show the number on a form (or a report) you can use format property like:
    FORMAT(Value [, Length] [, FormatStr/Number])

    where in the last optional parameter you enter <Precision,2:3><Standard Format,0>. In your case you would write <Precision,2:2><Standard Format,0> because u need only 2 decimal places. Of course you can put some other standard format instead of mentioned one.
    I hope it helps you.
  • arindamarindam Member Posts: 176
    Thank you very much for your suggestion. This solved my problem.
  • snyktpsnyktp Member Posts: 75
    Thank you thank you...
    This is the problem ; I used CLEARAL on preXMLProt . I didnt notice this :)
    I deleted it.It works correctly..
    Thank you for your help
  • ara3nara3n Member Posts: 9,256
    lol you are posting to the wrong thread.

    Here is the right one.

    viewtopic.php?f=14&t=34291


    and you are welcome. :D
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.