Recently a client asked me about the Excel function Days360. This is a commonly used function within the financial industry to calculate the number of days between two dates based on a 360 day year - i.e. 12 x 30day months.
The function in Excel takes 2 mandatory parameters and 1 optional parameter:
DAYS360(start_date,end_date,method)
If the "method" parameter is FALSE or left out, then it uses the US (NASD) method. If it is TRUE then it uses the European method. The difference is that in the European method if either the start or end date are on the 31st of the month, they are considered to be on the 30th of the month.
I have a simple VBScript function that replicates this functionality:
Function Days360(StartDate, EndDate, European)
Dim Days1, Days2 Days1 = Day(EndDate) Days2 = Day(StartDate)
If European and Days1 = 31 Then Days1 = 30 If European and Days2 = 31 Then Days2 = 30
Unfortunately VBScript doesn't have a MIN function or this could be reduced to be even simpler.
Now, if I define ths VBScript function in my QV Document, I can call it from within the load script in a QlikView application. Since version 8.2 though, I am unable to call macro functions from the chart so I have to have a different solution.
It is worth remembering. No matter what function that you come across that doesn't exist in QlikView, it has to be calcuable some way - and probably is do-able within QlikView.