|
-
Mar 4th, 2003, 08:37 AM
#1
Thread Starter
Lively Member
-
Mar 4th, 2003, 08:46 AM
#2
Frenzied Member
Hey, kid. Where's your best body Butch Cassidy, ha?
;-)
Anyway, you may use DateDiff function and substract 2 from the result.
-
Mar 4th, 2003, 09:03 AM
#3
McGenius, maybe you should reconsider your name here.
You can't just substract 2, because you must figure out the number of weekends first.
Here is a function i used before. I believe i stole half of it from this forum
VB Code:
Public Function NettoWorkdays(ByVal dtmStart As Date, ByVal dtmEnd As Date) As Integer
'This function calculates the number of working days (monday to friday) between 2 dates,
'including the first and the last day
Dim intDays As Integer
Dim intSubtract As Integer
' if end is smaller then start return -1
If dtmEnd < dtmStart Then
NettoWorkdays = -1
Else
' Get the start and end dates to be weekdays.
While WeekDay(dtmStart) = vbSaturday Or WeekDay(dtmStart) = vbSunday
dtmStart = dtmStart + 1
Wend
While WeekDay(dtmEnd) = vbSaturday Or WeekDay(dtmEnd) = vbSunday
dtmEnd = dtmEnd - 1
Wend
If dtmStart > dtmEnd Then
' Sorry, no Workdays to be had. Just return 0.
NettoWorkdays = 0
Else
intDays = dtmEnd - dtmStart + 1
' Subtract off weekend days. Do this by figuring out how
' many calendar weeks there are between the dates, and
' multiplying the difference by two (because there are two
' weekend days for each week). That is, if the difference
' is 0, the two days are in the same week. If the
' difference is 1, then we have two weekend days.
intSubtract = (DateDiff("ww", dtmStart, dtmEnd) * 2)
NettoWorkdays = intDays - intSubtract
End If
End If
End Function
-
Mar 4th, 2003, 09:08 AM
#4
Frenzied Member
Originally posted by Frans C
McGenius, maybe you should reconsider your name here.
You can't just substract 2, because you must figure out the number of weekends first ...[/Highlight]
Hey, you dummy, you better think before sending this s**** to me. If you're a PROGRAMMER then all need is an idea - the rest is upto capability if your brain and willingness of doing new things.
-
Mar 4th, 2003, 09:22 AM
#5
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|