VBA/Excel/Access/Word/Date Functions/DateSerial — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:48, 26 мая 2010
Содержание
DateSerial( returns 4
Sub dateDemo()
Debug.Print DateSerial(4, 11, 23)
End Sub
DateSerial(year, month, day) returns a Variant/Date containing the date for the specified year, month, and day
Sub dateDemo3()
Debug.Print DateSerial(1997, 7, 4)
End Sub
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
Use DateSerial and Weekday
Public Function DeliveryDateFast(intYear As Integer, intMonth As Integer)
Dim datStart As Date
datStart = DateSerial(intYear, intMonth, 8)
DeliveryDateFast = datStart + (7 - Weekday(datStart, vbThursday))
End Function
Sub Main()
Debug.Print DeliveryDateFast(1998,7)
End Sub