Funktsioon DatePart tagastab kuupäeva määratud osa.
Süntaks:
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
Tagastusväärtus:
The extracted part for the given date.
Parameetrid:
interval - A string expression from the following table, specifying the date interval.
interval (string value)
Selgitus
yyyy
Aasta
q
Kvartal
m
Kuu
y
Päev aastas
w
Nädalapäev
ww
Nädal aastas
d
Päev
h
Tund
n
Minut
s
Sekund
date - The date from which the result is calculated.
Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:
#yyyy-mm-dd#
#mm/dd/yyyy#
firstdayofweek: An optional parameter that specifies the starting day of a week.
firstdayofweek value
Selgitus
0
Kasutatakse süsteemi vaikeväärtust
1
Pühapäev (vaikimisi)
2
Esmaspäev
3
Teisipäev
4
Kolmapäev
5
Neljapäev
6
Reede
7
Laupäev
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
Selgitus
0
Kasutatakse süsteemi vaikeväärtust
1
Nädal 1 on nädal, mis sisaldab kuupäeva 1. jaanuar (vaikimisi)
2
Nädal 1 on nädal, mis sisaldab aasta nelja või enamat päeva.
3
Nädal 1 on nädal, mis sisaldab ainult alanud aasta päevi.
Näide:
Sub example_datepart
MsgBox DatePart("ww", #01/02/2005#) ' displays 2 because weeks start on Sunday
MsgBox DatePart("ww", #12/31/2005#) ' displays 53
MsgBox DatePart(date:=#2005-12-30#, interval:="q") ' displays 4
End Sub