Click here to Skip to main content
16,004,529 members
Articles / Programming Languages / Visual Basic
Article

Calculate Financial days between dates

Rate me:
Please Sign up or sign in to vote.
1.00/5 (2 votes)
13 Sep 20061 min read 47.1K   1.1K   16   3
How to calculate the difference between two dates using the Financial 360/360 year

Introduction

In some case for some financial instruments the difference between two dates has to be calculated in a special way...Not on a real 365-6 year, but on a financial constant year of 360 days. It means that in this case each month has 30 days (30days*12months=360days). The function to perform this calculation exist in Excel (DAYS360), but its not so comfortable to use it. So I preferred to create my personal formula...

Which is the trick?

It's very easy to understand the concept behind... You have to consider that an year is composed by 365.2422 days. It means that every 4 year a LEAP year happens. The financial year is of 360 days. The delta is of 5.2422 days. In this way you can perform the normal date difference calculation and the result has to be multiplied for the conversion factor that reduce a normal day to a day of an year 360 days long. In practice the calculation has to be 5.2422/365=0.985637808219178 (conversion factor).

Private Const Days360ConversionFactor As Double = 0.985637808219178

Now the only action you have to do is to keep the calculated usual date difference

Dim</FONT> DifferenceInDaysValue As Double = Me.EndPeriodDate.Value.Subtract(Me.StartPeriodDate.Value).Days

and multiply it per the conversion factor (that couls be assumed to be a constant).

This code could be easy implemented into a class or better into a financial dll to improve its reusability and deployment...

Now the DAYS360 exist also in Visual Studio .NET!!!

¦-D

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalfeb Pin
swapnamurrey28-Feb-07 1:02
swapnamurrey28-Feb-07 1:02 
Generaldaycount conventions Pin
thetaG19-Sep-06 4:48
thetaG19-Sep-06 4:48 
GeneralMinor Correction Pin
Mackay_S18-Sep-06 14:02
Mackay_S18-Sep-06 14:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.