Results 1 to 5 of 5

Thread: have a negative number just need to make it positve in sql

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    I am getting a result with in a column of say -1 how to I change this in sql by adding or whatever to make it 1?????

    Thanks Gurus

  2. #2
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    I'm not sure about SQL at all, but to turn a positive number to negative (or the other way round, conveniently enough ) just multiply it by -1 .

    Code:
    Dim Var As Integer
    Var = 5
    Form1.Print "Var = " & Var
    'Output: 5
    Var = Var * -1
    Form1.Print "Var = " & Var
    'Output: -5
    Courgettes.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    Yup so simple thank you!!!

  4. #4
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    Better late than never...

    You can also subtract a number from 0 to reverse the sign.

    Code:
    var = -10
    Debug.Print var, 0 - var
    Outputs:
    -10 10

    Don't worry if you don't know specific commands in languages for basic mathematical operations. Afterall, all ABS functions do is one of these operations (or possibly change the sign bit of the value using a bitwise operation)

    Regards
    Paul Lewis
    Paul Lewis

  5. #5
    Guest
    With the Abs-function you get the absolute value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width