Created
February 18, 2020 23:37
-
-
Save Azsaturndx/1310c6635fc51905bec9f8ac8aa13d95 to your computer and use it in GitHub Desktop.
EFFECT Function (Effective Annual Interest Rate) - SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Effective Annual Interest Rate | |
* (SQL Server) | |
* AzsaturnDx (2020) - No copyright at all | |
* | |
* Returns the effective annual interest rate, given the nominal annual interest rate and the number of compounding periods per year. | |
* | |
* @Rate FLOAT - Required. The nominal interest rate. | |
* @Periods INT - Required. The number of compounding periods per year. | |
* @return FLOAT Effective Annual Interest Rate. | |
* | |
* @Example | |
* SELECT dbo.EFFECT(0.452166555,52) | |
* | |
* More financial functions are available @: https://gist.github.com/Azsaturndx/8ce3e47e2d3210a65fc83b09ac32da5f | |
*/ | |
CREATE FUNCTION EFFECT( | |
@Rate FLOAT | |
,@Periods INT | |
) | |
RETURNS FLOAT | |
AS | |
BEGIN | |
IF (@Rate <= 0) OR (@Periods < 1) RETURN 0 | |
RETURN POWER( 1 + @Rate / @Periods, @Periods) - 1 | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment