0

I am currently working on defining workflow scripts in HP Application Lifecycle management tool using VB Script.

My problem is I have to generate an Excel chart for calculating the efforts put on by various developers in a particular Sprint(timeframe). In process of generating the same my condition is to eliminate the weekend dates(ie., Saturday and Sunday) from the chart. If the Sprint startdate falls on a weekend the date shoud automatically be initialized to the next immediate monday and if the Sprint End date falls on a weekend the end date should be displayed as the Friday that just passed. I have validated these two conditions. I am trying to shave off the Saturday and Sundays that come inbetween these two days. Please help me on the same. Also please let me know if you need any inputs from my side.

Abhishek Asthana
  • 1,857
  • 1
  • 31
  • 51

1 Answers1

0

@Sabaresh, I believe this is what you are looking for.

Tip: See this answer for information on downloading Microsoft's authoritative WSH reference as a Windows help file.

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
Community
  • 1
  • 1
DavidRR
  • 18,291
  • 25
  • 109
  • 191