Days360 Excel function for Access

J

Jerry

I need an Access function that is equivalent to the
DAYS360 function in Excel. Has anyone developed that?

TIA Jerry
 
D

david epsom dot com dot au

d1% = Day(pDateFrom)
m1% = Month(pDateFrom)
y1% = Year(pDateFrom)
d2% = Day(pDateTo)
m2% = Month(pDateTo)
y2% = Year(pDateTo)

ElseIf sDayBasis = "7" Or sDayBasis = "Excel30" Then

'30/360 PSA 30, NASD 30, used only by MS Excel and Quantum
'also: Excel simply backtracks by 3 or 6 months as
'appropriate. When it hits February 29th becomes 28th...
'they never go back to 29th. (that may be only in some
'versions of excel)

'handle last day in February (work with 1st day in march)
dtTemp1 = pDateFrom + 1
If (Day(dtTemp1) = 1) And (Month(dtTemp1) = 3) Then 'last day Feb
d1% = 30
End If

If (d2% = 31) And (d1% = 30) Then
d2% = 30
End If

gfnDayDiff = ((y2% - y1%) * 360) + ((m2 - m1) * 30) + (d2% - d1%)


Pretty much the same as Bloomberg/SIA/ISDA/MSRB/BMA if you
stay away from the end of the month. Which is one reason
why US bonds are typically issued on the 15th...

(david)
 
A

Arvin Meyer

Jerry said:
I need an Access function that is equivalent to the
DAYS360 function in Excel. Has anyone developed that?

Actually, you can set a reference to Excel and use that one. I like to wrap
it up like this:

Function XL360(Arg1, Arg2) as double
Dim objXL As New Excel.Application
XL360= objXL.WorksheetFunction.Days360(Arg1,Arg2)
Set objXL = Nothing
End Sub

Then:

XL360("1/1/2003", "12/31/2003")

will return 360

You also might like to have a look at the following:

http://www.mvps.org/access/modules/mdl0007.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Top