Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: deepsee3 am 07.06.02 - 09:51:42

Titel: Anzahl Tage berechnen
Beitrag von: deepsee3 am 07.06.02 - 09:51:42
Hat jemand ne Idee wie man die Anzahl der Tage aus zwei Datumsfelder berechnet ohne die Samstage und Sonntage zu berücksichtigen ?

Also Problem :
Anfangsdatum Urlaub : 01.01.02 ( Eingabefeld )
Enddatum Urlaub : 02.02.02 ( Eingabefeld )
Anzahl Arbeitstage : xx ( berechnet )

Ich komm da mit meiner @formular irgendwie nicht weiter ... :-[

Titel: Re: Anzahl Tage berechnen
Beitrag von: fritandr am 07.06.02 - 10:16:17
Hallo,

ich habe so was in Formelsprache.

--------
tab:=@Char(9);
nl:=@Char(10);
FIELD StartDate:=vom;
FIELD EndDate:=bis;

diffDays := (EndDate - StartDate) / 86400 + 1;
strtDay := @Modulo(@Weekday(StartDate); 7);
endDay := @Modulo(@Weekday(EndDate); 7);
result := (diffDays - endDay + strtDay - 8) * 5 / 7 - @Max(-2; -strtDay) - @Min(1; endDay) + 5 - strtDay + endDay;
@SetField("TageUrlaub"; result)

--------

Achtung! Feiertage werden hier leider nicht berücksichtigt.

Ciao
Andreas
Titel: Re: Anzahl Tage berechnen
Beitrag von: Gulliver am 07.06.02 - 10:44:02
Hallo,

ich hab' da was aus LS; ist aber nicht auf meinem Mist gewachsen  ::), ist aus 'nem Lehrgang (c by R. Krappweis)

Sub Set_CalendarDateTime_HDays (uidoc As NotesUIDocument)
     
     Dim doc As NotesDocument
     Set doc = uidoc.Document
     
     Dim DateList () As Variant
     
     Dim Tag As Variant
     Dim AnzahlTage As Integer
     Dim i As Integer
     Dim j As Integer
     
     AnzahlTage = doc.EndDate(0) - doc.StartDate(0)
     
     Dim tmpDate As Variant
     Dim wd As Integer
     
     For i = 0 To AnzahlTage
           tmpDate = doc.StartDate(0) + i
           wd = Weekday(tmpDate)
           If (wd > 1) And (wd < 7) Then   '-- Falls Wochentag (Mo - Fr)
                 Redim Preserve DateList(j)              
                 DateList(j) = tmpDate
                 j = j + 1
           End If
     Next
     
     doc.CalendarDateTime = DateList
     doc.HDays = j
     
End Sub
Titel: Re: Anzahl Tage berechnen
Beitrag von: deepsee3 am 07.06.02 - 11:35:48
Hi

8) fritandr  = funzt

:( Gulliver = nö

Danke euch beiden ... werde mal versuchen ob ich das mit dem Script noch hinkriege ...

thx