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

Code problems..dtmTemp = DateAdd("d", 1, dtmTemp)

Status
Not open for further replies.

hello101

Instructor
Jun 26, 2006
18
US
I copied this code from the forum. There's a problem on this line: dtmTemp = DateAdd("d", 1, dtmTemp)
what's wrong with it. Tks



Public Function NextWorkDay(dtmDate As Date) As Date

'****************************************
'Created By: Robert L. Johnson III
'Mod Date: February 19, 2003
'Purpose: Determine the next business (working) day
'In: dteDate is the date to be checked
'Out: Returns the next business day
'Example: NextWorkDay(#12/31/02#) returns 1/2/03
' (1/1/01 is a holiday (New Year's Day))
'****************************************

Dim dtmTemp As Date
Dim blnNextWorkday As Boolean

dtmTemp = dtmDate + 1
blnNextWorkday = False
Do Until blnNextWorkday = True
If IsWeekend(dtmTemp) = True Or IsHoliday(dtmTemp) = True Then
dtmTemp = DateAdd("d", 1, dtmTemp)
Else
blnNextWorkday = True
End If
Loop
NextWorkDay = dtmTemp

End Function
 
It is always best to post a link to the thread or FAQ that you have referred to. In this case, I think it would be best to look at the original FAQ by MichaelRed:
Calculating a future Workday Date
faq705-3213
 
Obviously:
dtmTemp = DateAdd("d", 1, dtmTemp)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top