Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

SQL Rounding problem with a TSQL formula?

POWER(.5,DateDiff(day,NT.ActDate,GetDate()) / Convert(float,N.HalfLifeInDays)) * NT.Activity AS DECAYACTIVITY,

In one record, the decay days = 5657,

the activity = 0.00452

the halflife in days = 4503.5325

so .5 ^ ( 5657 /4503.5325) * 0.00452 = 0.00189237462344581210679712673579

But the SQL results = 0.001808

Any ideas on how to get better precision?

1 Answer

Relevance
  • 7 years ago
    Favorite Answer

    I may not be using the right terms, but it looks like this has to do with the scale of your base (how many 0's after the .5).

    If you run the same query as: POWER(.5000000000,DateDiff(day,NT.ActDate,GetDate()) / Convert(float,N.HalfLifeInDays)) * NT.Activity AS DECAYACTIVITY -- you get a result of 0.001892375

    If you run the same query as: POWER(.500000000000000000000000000000000,DateDiff(day,NT.ActDate,GetDate()) / Convert(float,N.HalfLifeInDays)) * NT.Activity AS DECAYACTIVITY -- you get a result of 0.00189237462344581192800000000000

Still have questions? Get your answers by asking now.