- Mar 1, 2000
- 30,890
- 5,001
- 126
I'm attempting to use the coding provided under the "UDF to return the number of business days, including a check to a bank holidays table" (towards bottom) provided on the following page:
http://msdn.microsoft.com/en-us/library/ms189794(v=sql.90).aspx
I have created a "holidays" table with our 2011 holidays listed.
However, it seems to be giving me wrong data back.
using: dbo.fnGetBusinessDays('09/01/2011','09/30/2011') for September it returns 20 business days, when there are 21 (22 days of the week - 1 paid holiday)
using dbo.fnGetBusinessDays('10/01/2011','10/31/2011') for October it returns 21 (this is correct as there are no holidays)
using dbo.fnGetBusinessDays('11/01/2011','11/30/2011') for November it returns 19 business days, when there are 20 (22 days of the week - 2 paid holidays)
using dbo.fnGetBusinessDays('12/01/2011','12/31/2011') for December it returns 19 business days when there are 20 (22 days of the week - 2 paid holidays)
These are the entries in the bankholidays table:
2011-09-05 00:00:00.000
2011-11-24 00:00:00.000
2011-11-25 00:00:00.000
2011-12-23 00:00:00.000
2011-12-26 00:00:00.000
Anyone have any thoughts?
...or anyone have a BETTER way to calculate # of business days that includes holiday schedule?
Thanks in advance.
http://msdn.microsoft.com/en-us/library/ms189794(v=sql.90).aspx
I have created a "holidays" table with our 2011 holidays listed.
However, it seems to be giving me wrong data back.
using: dbo.fnGetBusinessDays('09/01/2011','09/30/2011') for September it returns 20 business days, when there are 21 (22 days of the week - 1 paid holiday)
using dbo.fnGetBusinessDays('10/01/2011','10/31/2011') for October it returns 21 (this is correct as there are no holidays)
using dbo.fnGetBusinessDays('11/01/2011','11/30/2011') for November it returns 19 business days, when there are 20 (22 days of the week - 2 paid holidays)
using dbo.fnGetBusinessDays('12/01/2011','12/31/2011') for December it returns 19 business days when there are 20 (22 days of the week - 2 paid holidays)
These are the entries in the bankholidays table:
2011-09-05 00:00:00.000
2011-11-24 00:00:00.000
2011-11-25 00:00:00.000
2011-12-23 00:00:00.000
2011-12-26 00:00:00.000
Anyone have any thoughts?
...or anyone have a BETTER way to calculate # of business days that includes holiday schedule?
Thanks in advance.
