title image


Smiley Re: Anzahl Wochentage zwischen 2 Daten
Hi !



Hab' da was gefunden.

Ist zwar nicht auf meinem Mist gewachsen, aber vielleicht hilft es Dir ja.



Function DateDiffW(ByVal BegDate As Date, EndDate As Date) As Long

'PSS ID Number: Q95977

'Article last modified on 08-29-1997

'The following code provides a function, DateDiffW(), that calculates

'the number of work days between two dates:

'

'How to Use the DateDiffW() Function

'-----------------------------------

'

'Use the DateDiffW() function wherever you would use DateDiff(). Instead of

'

' DateDiff("W",[StartDate],[EndDate])

'

'use the following:

'

' DateDiffW([StartDate],[EndDate])

'

'NOTE: This function returns the days UP TO the ending date, not UP TO and

'INCLUDING the ending date.

'One less than AnzWochenTage



' Anzahl Werktage (ohne Feiertage) zwischen zwei Tagen

Const SUNDAY = 1

Const SATURDAY = 7

Dim NumWeeks As Long



If BegDate > EndDate Then

DateDiffW = 0

Else

Select Case Weekday(BegDate)

Case SUNDAY: BegDate = BegDate + 1

Case SATURDAY: BegDate = BegDate + 2

End Select

Select Case Weekday(EndDate)

Case SUNDAY: EndDate = EndDate - 2

Case SATURDAY: EndDate = EndDate - 1

End Select

NumWeeks = DateDiff("ww", BegDate, EndDate)

DateDiffW = NumWeeks * 5 + Weekday(EndDate) - Weekday(BegDate)

End If

End Function





Gruß

flipper8

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: