dr.cornwallis
Goto Top

Gibt es in Access eine Möglichkeit die Anzahl der Arbeitstage auszugeben

Liebe Gemeinde,

gibt es in Access wie in Excel eine Funktion die die mon. Arbeitstage ausgibt(Excel - Nettoarbeitstage)?


Danke für eure Hilfe/Tipps

Gruß

Dr.

Content-Key: 313554

Url: https://administrator.de/contentid/313554

Printed on: April 25, 2024 at 06:04 o'clock

Mitglied: 129813
129813 Aug 25, 2016 updated at 11:41:50 (UTC)
Goto Top
http://www.office-loesung.de/ftopic70050_0_0_asc.php
or you could also do
Set objExcel = CreateObject("Excel.Application")  
days = objExcel.WorksheetFunction.NetworkDays(CDate("01.01.2016"), CDate("05.01.2016"))  
objExcel.Quit
MsgBox days
Regards
Member: Kraemer
Solution Kraemer Aug 25, 2016 at 11:47:45 (UTC)
Goto Top
Function Work_Days(BegDate As Variant, EndDate As Variant) As Integer 
 
 Dim WholeWeeks As Variant 
 Dim DateCnt As Variant 
 Dim EndDays As Integer 
 
 On Error GoTo Err_Work_Days 
 
 BegDate = DateValue(BegDate) 
 EndDate = DateValue(EndDate) 
 WholeWeeks = DateDiff("w", BegDate, EndDate)   
 DateCnt = DateAdd("ww", WholeWeeks, BegDate)   
 EndDays = 0 
 
 Do While DateCnt <= EndDate 
 If Format(DateCnt, "ddd") <> "Sun" And _   
 Format(DateCnt, "ddd") <> "Sat" Then   
 EndDays = EndDays + 1 
 End If 
 DateCnt = DateAdd("d", 1, DateCnt)   
 Loop 
 
 Work_Days = WholeWeeks * 5 + EndDays 
 
Exit Function 
 
 Err_Work_Days: 
 
 ' If either BegDate or EndDate is Null, return a zero   
 ' to indicate that no workdays passed between the two dates.   
 
 If Err.Number = 94 Then 
 Work_Days = 0 
 Exit Function 
 Else 
' If some other error occurs, provide a message.   
 MsgBox "Error " & Err.Number & ": " & Err.Description   
 End If 
 
End Function

Quelle
Member: Dr.Cornwallis
Dr.Cornwallis Aug 29, 2016 at 08:49:42 (UTC)
Goto Top
Danke für eure Antworten, das ist leider noch nicht ganz das was ich benötige.

Ich bräuchte diese Werte für eine Access Query, bei dieser sollen im Feld mit Datumswerten als Kriterium die ersten 5 Werktage/Arbeitstage im Monat gefiltert werden.

Bis jetzt habe ich die Vorwoche als Kriterium:

=Datum()-Wochentag(Datum())-5 Und <=Datum()-Wochentag(Datum())-1

Danke!

Gruß

Dr.
Member: Dr.Cornwallis
Dr.Cornwallis Aug 29, 2016 at 08:51:19 (UTC)
Goto Top
Sorry, falscher Thread face-smile
Mitglied: 129813
129813 Aug 29, 2016 updated at 08:56:51 (UTC)
Goto Top
In case you don't know, every VBA Function can be written to be also used in access expressions face-wink