Delivery Date Maint : DateSerial « Date Functions « VBA / Excel / Access / Word






Delivery Date Maint

 
Sub Main()
    Debug.Print DeliveryDateMaint(1998,12)
End Sub
Public Function DeliveryDateMaint(intYear As Integer, intMonth As Integer)
    Dim datStart        As Date
    datStart = DateSerial(intYear, intMonth, 8)
    Select Case Weekday(datStart, vbSunday)
    Case vbSunday
        DeliveryDateMaint = datStart + 3
    Case vbMonday
        DeliveryDateMaint = datStart + 2
    Case vbTuesday
        DeliveryDateMaint = datStart + 1
    Case vbWednesday
        DeliveryDateMaint = datStart
    Case vbThursday
        DeliveryDateMaint = datStart + 6
    Case vbFriday
        DeliveryDateMaint = datStart + 5
    Case vbSaturday
        DeliveryDateMaint = datStart + 4
    End Select

End Function

 








Related examples in the same category

1.DateSerial(year, month, day) returns a Variant/Date containing the date for the specified year, month, and day
2.DateSerial(4, 11, 23) returns 11/23/2004
3.Use DateSerial and Weekday