Why does this result in 0 ?

  • SELECT Convert(float,(15/24))

  • Because it is all implicit conversion here. First you devide the integer 15 by 24. As being all integers this results in a integer being 0. And converting 0 to a float still results in 0.

    Try this:

    SELECT Convert(float,15)/24

    This first converts the 15 to a float. Implicitly the result of the division will also be a float.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • Or SELECT 15.0/24.0

  • Thanks guys...that was not obvious to me.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply