vb.netdts

Visual Basic Time Variable for DTS packages


I am converting some DTS packages over from Visual Basic to C# and am wondering what @OldDate the following would produce. I am not a VB.NET guy and really do not have the time to play around with this..and it has to be correct so I am reaching out to SO!!

datActionDate = Now()
intNumberOfDays = 365
businessDays = 0

Set .ActiveConnection = objConnection
    .CommandType = 4
    .CommandText = strStoredQuery
    .Parameters.Append .CreateParameter("@OldDate",7,1,8,CDate(datActionDate))
    .Execute

Any assistance would be greatly appreciated!!

*Edit the datActionDate is a number from a do loop. holidayLs is basically checking that date against a list of dates

do until bdays = intNumberOfDays
    datActionDate = DateAdd("d", -1, datActionDate)
    if weekday(datActionDate) > 1 and weekday(datActionDate) < 7 then
        if not holidayLs(datActiondate) then
            businessDays = businessDays + 1
        end if
    end if
loop

Solution

  • After picking up a basic understanding about VB enough to read this code, I have found that this question is less about syntax and more about just working through the logic. The @OldDate will end up being a number around 470 days from today given

    DateAdd("d", -1, datActionDate)
    

    is subtracting a day from datActionDate which is defined as

    datActionDate = Now()
    

    I was unfamiliar with the weekday() which just yields a numerical day. So the following statement

    if weekday(datActionDate) > 1 and weekday(datActionDate) < 7 then
    

    Is basically looking for days that are not Saturday and Sundays (for which there are 105 in a year - which will be the MINIMUM decremented from today)

    When subtracting holidays that are in the holidaysLs (for which there are about 11) in this line

    if not holidayLs(datActiondate) then
    

    Then datActionDate = Saturday, November 24, 2018