@Sabaresh,我相信这就是你要找的。
提示:有关将 Microsoft 的权威 WSH 参考下载为 Windows 帮助文件的信息,请参阅此答案。
Option Explicit
Dim dCandidateDate, dActualStartDate, dActualEndDate
dCandidateDate = CDate("2012/08/18")
dActualStartDate = SprintStartDate(dCandidateDate)
dCandidateDate = CDate("2012/09/16")
dActualEndDate = SprintEndDate(dCandidateDate)
WScript.Echo "Sprint date range: " _
& dActualStartDate & " through " & dActualEndDate
'
' Return following Monday if dCandidateDate is
' Saturday or Sunday.
'
Function SprintStartDate(dCandidateDate)
Dim nWeekday : nWeekday = DatePart("w", dCandidateDate)
Select Case nWeekday
Case 7 ' Saturday
SprintStartDate = DateAdd("d", 2, dCandidateDate)
Case 1 ' Sunday
SprintStartDate = DateAdd("d", 1, dCandidateDate)
Case Else
SprintStartDate = dCandidateDate
End Select
End Function
'
' Return previous Friday if dCandidateDate is
' Saturday or Sunday.
'
Function SprintEndDate(dCandidateDate)
Dim nWeekday : nWeekday = DatePart("w", dCandidateDate)
Select Case nWeekday
Case 7 ' Saturday
SprintEndDate = DateAdd("d", -1, dCandidateDate)
Case 1 ' Sunday
SprintEndDate = DateAdd("d", -2, dCandidateDate)
Case Else
SprintEndDate = dCandidateDate
End Select
End Function