SSRS 2012 converting Data field

  • RCPORTILLO98

    Valued Member

    Points: 62

    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

  • Andrew P

    SSCarpal Tunnel

    Points: 4463

    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

  • Ken Hiatt

    SSC-Addicted

    Points: 429

    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.

  • gvoshol 73146

    Hall of Fame

    Points: 3092

    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

     

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

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