YEARFRAC
Updated: 23 May 2016
Use YEARFRAC to calculate the fraction of the year represented by the number of whole days between two dates. 
 
Syntax
SELECT [westclintech].[wct].[YEARFRAC] (
  <@Start_date, datetime,>
 ,<@End_date, datetime,>
 ,<@Basis, nvarchar(4000),>)
Arguments
@Start_date
the start date for the calculation. @Start_date is an expression that returns a datetime or smalldatetime value, or a character string in date format. 
@End_date
the end date of the security. @End_date is an expression that returns a datetime or smalldatetime value, or a character string in date format. 
@Basis
Is the type of day count to use. @Basis is an expression of the character string data type category.
 
    
        
            | @Basis | Day count basis  | 
        
            | 0 or omitted | US (NASD) 30/360 | 
        
            | 1 | Actual/Actual | 
        
            | 2 | Actual/360 | 
        
            | 3 | Actual/365 | 
        
            | 4 | European 30/360 | 
        
            | 21 | Actual/ISDA | 
    
 
Return Type
float
Remarks
·         If the @Basis is not 0, 1, 2, 3, 4, or 21, YEARFRAC returns an error
Example
 Select wct.YEARFRAC('02/29/2008'
,'03/31/2008'
,0)
 
Here is the result set
----------------------
0.0861111111111111
See Also