Danke,
und jetzt noch der umgekehrte Weg:
Wenn ich dann zb. KW 39 auswähle, wie komm ich dann per Script zurück auf das aktuelle Startdatum der Woche also Weekday=1?
Ich hab folgendes Script gefunden:
Function Datum_KW(nKW As Integer, nYear As Integer) As Date
On Error GoTo Err_Datum_KW
Dim d As Integer
Dim vDate As Date
vDate = "01.01." & CStr(nYear)
For d = 0 To 6
If Format(vDate + d, "ww", vbMonday, vbFirstFourDays) = 1 Then
Datum_KW = vDate + d + (nKW - 1) * 7 - 2
Datum_KW = Datum_KW - (Weekday(Datum_KW, vbMonday) - 1)
End If
Next d
Exit Function
Err_Datum_KW:
MsgBox Err.Description
End Function
Sieht da jemand ein Problem, außer das es noch an Notes angepasst werden muss, oder sollte das funktionieren?
Danke robert
Ich möchte meine Lösung niemanden vorenthalten:
Function Datum_KW(Woche As Integer, Jahr As Integer)
Dim intTag As Integer, intWoche As Integer
If Jahr = 0 Then
Datum_KW = 0
Exit Function
End If
intTag = 1
intWoche = KalenderWoche(Datenumber(Jahr, 1, 1))
If intWoche <> 1 Then
Do Until KalenderWoche(Datenumber(Jahr, 1, intTag)) = 1
intTag = intTag + 1
Loop
Else
Do Until KalenderWoche(Datenumber(Jahr, 1, intTag)) <> 1
intTag = intTag - 1
Loop
intTag = intTag + 1
End If
Datum_KW = Datenumber(Jahr, 1, intTag) + (Woche - 1) * 7
End Function
Function KalenderWoche(Datum As String) As Integer
Dim tmp As Double
Dim dDay As NotesDateTime
Dim dDaytemp As NotesDateTime
Set dDay = New NotesDateTime(Datum)
Set dDaytemp =New NotesDateTime(Datum)
Call dDay.AdjustDay((8 - Weekday(dDay.DateOnly)) Mod 7 - 3)
tmp = Datenumber(Year(dDay.DateOnly), 1, 1)
KalenderWoche = ((Cdat(dDaytemp.DateOnly)) - (Cdat(tmp - 3 + (Weekday(tmp) +1) Mod 7))) / 7 + 1
End Function
Vielleicht geht es einfacher auch! Aber es funktioniert! So ermittle ich anhand der KW den ersten Tag in der Woche.
gruss robert