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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Banking Days and VB

Status
Not open for further replies.

forweefolks

Technical User
May 3, 2001
6
FI
Hi there,

Anyone having an idea of how to build a banking day calendar to VB? That is code that could take into account days, when New York or London are not open for business, and give a yes/no result if a date in future falls on a date on which banks are open for business?

Help would be much appreciated,

Mika
 
Well, it isn't so different from "working days". there is FAQ (faq-181-261) which calculates "Working Days". You could adapt it to return a boolean for wheather an input date was a "Banking Day" or a Banking Holiday".

The approach would be to set up the list of "Bank Holidays" in a table. The routine would just check the input date to see if it were a "Bank Holiday". I would only include real "holidays" in the table, and do the weekday calculation for the Sunday part.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Michael,

How do I find that faq you referenced. I tried just clicking on the fac tab but wasn't sure what the exact title of the faq would be. Can you help me?

Thanks,
Corinne
 
I found a link to this site through some helpful people here This is what I found.

Date: 10/7/2000
Versions: VB4 VB5 VB6 VBS Level: Intermediate
Author: The VB2TheMax Team

' evaluate the number of business days between two dates
'
' Note that it doesn't take Christmas, Easter and
' other holidays into account

Function BusinessDateDiff(ByVal StartDate As Date, ByVal EndDate As Date, _
Optional ByVal SaturdayIsHoliday As Boolean = True) As Long
Dim incr As Date

' ensure we don't take time part into account
StartDate = Int(StartDate)
EndDate = Int(EndDate)

' incr can be +1 or -1
If StartDate < EndDate Then incr = 1 Else incr = -1

Do Until StartDate = EndDate
' skip to previous or next day
StartDate = StartDate + incr
If Weekday(StartDate) <> vbSunday And (Weekday(StartDate) <> vbSaturday _
Or Not SaturdayIsHoliday) Then
' if it's a weekday add/subtract one to the result
BusinessDateDiff = BusinessDateDiff + incr
End If
Loop
' when the loop is exited the function name
' contains the correct result

End Function


Hope that helps :)

Joanne
 
Carmilita,

You should be able to just cllick on the faq in the post faq181-261 It &quot;should have been&quot; ... underlined. I guess the parens confused the psrser as much as they were supposed to clarify the intent to you. Sorry about that.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Carmilita,

You should have been (NOW be) able to just cllick on the faq in the post (faq181-261). It &quot;should have been&quot; ... underlined. I just erred in inserting an extra Dask. Sorry about that.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top