I know that this is not a mainstream issue, but those who are familiar with Excel's DAYS360 function would know this problem.
Shortly, "DAYS360" is an Excel function that calculates the number of days between two dates,
regarding that each month is composed of 30 days. This feature is generally used in financial markets.
While I was dealing with Bloomberg API integration with a C# code, I faced the problem. One of my friends shared his formula of calculating the correct interval. This is the way Bloomberg system calculates DAYS360 style date intervals :
|
public static int CalculateDays360(DateTime d1, DateTime d2)
{
int years = d2.Year - d1.Year;
int months = d2.Month - d1.Month;
int dayNo1 = 0;
int dayNo2 = 0;
dayNo2 = d2.Day;
dayNo1 = d1.Day;
|