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

Date Calculations

Status
Not open for further replies.

Shorty10

MIS
Nov 28, 2007
3
US
How do I adapt the following or what code could I use so that weekends are ignored in calculating future dates? For example: If the user selects April 11 from the calendar control as the FirstDate and wants to know the date 5 business (weekday)days from that date how would this be accomplished?

I'm also trying to ignore holidays (I have a holiday table).


Private Sub Command14_Click()

Dim FirstDate As Date 'Declare variables
Dim IntervalType As String
Dim Number As Integer
Dim Msg
IntervalType = "d" '"d" specifies months as interval
FirstDate = Calendar1
Number = InputBox("Enter number of days to add")
Msg = "New date: " & DateAdd(IntervalType, Number, FirstDate)
MsgBox Msg
Exit_Command14_Click:
Exit Sub


End Sub
 
Did you look at any of the several FAQs in this forum related to date calculations?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
please save those who are trying to help YOR by not postiing the same question in several different fori at the same time. They usually visit several forums on a regular basis and may end up reviewing your question in one forum while another has alrady responded to your inquiry elsewhere. In effect, when you do this you consume the resources and thus deprive someone else of the benefit of those who have needlessly stoped to peruse you question.



MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top