Professional Web Applications Themes

help conversion problem - Microsoft SQL / MS SQL Server

Hi All, I want to convert a character data type into numeric but im having problem when dividing a number which is less than the denominator. It returns 0. what seems to be the problem. here is my query... CONVERT(int, SUM(Duration/60)) As TotalMins...

  1. #1

    Default help conversion problem

    Hi All,

    I want to convert a character data type into numeric but im having problem
    when dividing a number which is less than the denominator. It returns 0.
    what seems to be the problem. here is my query...


    CONVERT(int, SUM(Duration/60)) As TotalMins


    Joel Guest

  2. #2

    Default Re: help conversion problem

    Hi Joel,

    Duration/60 already does an implicit conversion of Duration to an INT
    datatype. And if you divide an int by an int, the result will always be
    rounded down.

    There are a few options that will return the result you expect:
    CONVERT(int, SUM(Duration/60.)) As TotalMins -- Note the dot.
    CONVERT(int, SUM(CAST(Duration AS FLOAT)/60)) As TotalMins
    SUM(CAST(Duration AS INT))/60 As TotalMins


    --
    Jacco Schalkwijk MCDBA, MCSD, MCSE
    Database Administrator
    Eurostop Ltd.


    "Joel Gacosta" <com> wrote in message
    news:#phx.gbl... 


    Jacco Guest

  3. #3

    Default Re: help conversion problem


    Try this

    CONVERT(int, SUM(Duration/60.0)) As TotalMins

    Praveen Maddali
    MCDBA, MCSD

    "Joel Gacosta" <com> wrote in message
    news:#phx.gbl... 


    praveen Guest

  4. #4

    Default Re: help conversion problem

    thanks for your immediate response. i tried what were stated below but i got
    an error message:

    'Arithmetic overflow error converting numeric to datat type numeric'

    thanks again,
    joel

    "Jacco Schalkwijk" <co.uk> wrote in message
    news:#phx.gbl... [/ref]
    problem 
    >
    >[/ref]


    Joel Guest

Similar Threads

  1. Pdf conversion problem
    By steve_grunyk@adobeforums.com in forum Adobe Indesign Macintosh
    Replies: 2
    Last Post: November 19th, 10:21 PM
  2. MD5 conversion problem
    By Peter Afonin in forum ASP.NET Security
    Replies: 15
    Last Post: September 1st, 09:48 PM
  3. Conversion problem
    By David_COHEN4@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 0
    Last Post: April 18th, 02:55 PM
  4. Font conversion problem
    By Jack_Harich@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 3
    Last Post: April 1st, 03:59 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139