Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date calculation on 360 day basis

Status
Not open for further replies.

Numbers1

Technical User
Dec 27, 2003
34
US
Excel has a function Days360 which is used to calculate the number of days between 2 dates as if each month had 30 days. It appears VBA does not have that function. DateDiff uses a 365 day calendar.
Does anyone know how to calculate on the basis of a 360 day calendar when finding the number of days between 2 dates?
I am using this in a formula in my code as follows:
PrincipalAmt x CouponRate x (Date1 - Date2) / 360 = AccruedInterest in the period
 
For the dates I tested this seemed to work


StartYear = Year(StartDate)
EndYear = Year(EndDate)
StartMonth = Month(StartDate)
EndMonth = Month(EndDate)
If Day(StartDate) > 30 Then
Startday = 30
Else
Startday = Day(StartDate)
End If
If Day(EndDate) > 30 Then
EndDay = 30
Else
EndDay = Day(EndDate)
End If

DayCount = ((EndYear - StartYear) * 360) + ((EndMonth - StartMonth) * 30) + (EndDay - Startday)
 
And what about this ?
Application.WorksheetFunction.Days360(Date1, Date2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV seems to be on the right track. Date1 and Date2 populate but no result occurs. I used the following:
DayCount = Application.WorksheetFunction.Days360(Date1,Date2)
What is missing to get a the resulting # of days?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top