SQL Server TBILLYIELD Function
Updated 2023-10-05 20:01:45.133000
Description
Use the scalar function TBILLYIELD to calculate the yield for a Treasury bill
Syntax
SELECT [westclintech].[wct].[TBILLYIELD] (
<@Settlement, datetime,>
,<@Maturity, datetime,>
,<@Pr, float,>)
Arguments
@Settlement
the settlement date of the security. @Settlement is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@Maturity
the maturity date of the security. @Maturity is an expression that returns a datetime or smalldatetime value, or a character string in date format.
@Pr
the security's price per 100 face value. @Pr is an expression of type float or of a type that can be implicitly converted to float.
Return Type
float
Remarks
If @Pr <= 0 TBILLYIELD returns an error.
If @Settlement >= @Maturity TBILLYIELD returns an error.
If @Maturity is more than 1 year after @Settlement TBILLYIELD returns an error
The following formula is used: TBILLYIELD = (100-@Pr) / @Pr*360/DSM
Where
DSM is the number of days from @Settlement to @Maturity
Examples
SELECT wct.TBILLYIELD('2/1/2008', '6/1/2008', 98.75);
Here is the result set.
| column 1 |
|---|
| 0.0376608431844335 |