SSRS 2012 converting Data field

  • How do you convert a Data field that is feet to miles on a expression.

    For instance the name of the field is PipeLen.value

  • According to CalculateMe.com the length of a mile is 0.00018939394 feet.

    The SSRS expression to do this is:

    =Fields!PipeLen.Value * 0.00018939394

    Best,

    Andrew

  • Since 1 mile is 5280 feet and your field is storing the data in feet, just divide your field by 5280.

    When you divide 1 by 5280 you get .000189393 with the 93 repeating to infinity, so to use multiplication to get your answer, you lose accuracy. Ex. Working with a 10 digit decimal, 5280 * .0001893934 = 1.0000000032, whereas 5280 / 5280 = 1.

  • Don't forget to use floating-point math, not integer math, when you're dividing by 5280.

    For example, 660 feet is 1/8 of a mile.

    SELECT 660/5280
    SELECT 660/5280.0

    The result of the first statement is 0 because it is using integer math and it rounds to the nearest integer result

    The result of the second statement is the expected value of 0.125

     

    • This reply was modified 5 years, 3 months ago by  GaryV.
    • This reply was modified 5 years, 3 months ago by  GaryV.

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

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