DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
Návratová hodnota:
The extracted part for the given date.
Parameters:
interval - A string expression from the following table, specifying the date interval.
interval (string value)
Vysvetlenie
yyyy
Rok
q
Štvrtina
m
Mesiac
y
Deň v mesiaci
w
Pracobný deň
ww
Týždeň v roku
d
Deň
h
Hodina
n
Minúta
s
Sekunda
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
Vysvetlenie
0
Použiť prednastavenú systémovú hodnotu
1
Nedeľa (prednastavená hodnota)
2
Pondelok
3
Utorok
4
Streda
5
Štvrtok
6
Piatok
7
Sobota
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
Vysvetlenie
0
Použiť prednastavenú systémovú hodnotu
1
Týždeň 1 je týždeň, ktorý obsahuje 1. január (prednastavená hodnota)
2
Týždeň 1 je prvý týždeň obsahujúci 4 alebo viac dní tohto roka
3
Týždeň 1 je prvý týždeň obsahujúci iba dni tohto roka
Example:
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