Trunc function in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • salzan
    New Member
    • Feb 2008
    • 38

    Trunc function in Access

    I feel stupid for acking but is there an equavelent function to Trunc in Access? Int and Fix funtions all do rounding to neareast integer, I need a way to extract only the integer portion of a decimal number.
    Thanks for the help
    Feeling Stupid...
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    In my testing, the Int() function does just what you are wanting. It doesn't round to the nearest value.

    Regards,
    Scott

    Comment

    • Scott Price
      Recognized Expert Top Contributor
      • Jul 2007
      • 1384

      #3
      If you feel like testing my claim :-) Go into the Immediate window of your VBA code editor. (Press Alt+F11 from inside Access to open the editor window) and type ?Int(2.99999999 ) then press enter. The result is 2.

      Regards,
      Scott

      Comment

      • salzan
        New Member
        • Feb 2008
        • 38

        #4
        Thank you all, greatly appreciate it.
        Salzan

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by salzan
          I feel stupid for acking but is there an equavelent function to Trunc in Access? Int and Fix funtions all do rounding to neareast integer, I need a way to extract only the integer portion of a decimal number.
          Thanks for the help
          Feeling Stupid...
          FYI, both Fix() and Int() will work for Positive Numbers. They both will remove the fractional part of number and return the resulting integer value.

          The only difference between Int and Fix is that if a number is negative, Int returns the first negative integer less than or equal to the number, whereas Fix returns the first negative integer greater than or equal to the number.

          For example:
          [CODE=vb]
          Int(-8.4) ==> returns -9
          Fix(-8.4) ==> returns -8[/CODE]

          Comment

          Working...