DatePart Function
α’αα»αααα DatePart αααα‘ααβαααααβααβααΆαααα·α
ααααβαααααΆαβαααααΆααΒ α
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
αααααβαααα‘αα α
The extracted part for the given date.
interval - A string expression from the following table, specifying the date interval.
interval (string value)
|
ααα
ααααΈβαααααα
|
yyyy
|
ααααΆα
|
q
|
αα½αβααΆαβαα½α
|
m
|
αα
|
y
|
ααααβααβααααΆα
|
w
|
ααααβααααΎααΆα
|
ww
|
αααααΆα αβααβααααΆα
|
d
|
αααα
|
h
|
αααα
|
n
|
ααΆααΈ
|
s
|
αα·ααΆααΈ
|
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
|
ααα
ααααΈβαααααα
|
α
|
ααααΎβαααααβααααΆαααΎαβαααααααα
|
α‘
|
ααααβα’αΆαα·ααα (ααααΆαααΎα)
|
α’
|
ααααβα
αααα
|
α£
|
ααααβα’ααααΆα
|
α€
|
ααααβαα»α
|
α₯
|
ααααβαααα ααααα·α
|
α¦
|
αα»ααα
|
α§
|
αα
αα
|
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
|
ααα
ααααΈβαααααα
|
α
|
ααααΎβαααααβααααΆαααΎαβαααααααα
|
α‘
|
αααααΆα αα‘ ααΊβααΆβαααααΆα αβαααβααΆα ααααβααΈα‘ ααβααααΆ (ααααΆαααΎα)
|
α’
|
αααααΆα αα‘ ααΊβααΆβαααααΆα αβααΈαα½α αααβααΆαβαα½α α¬βα
αααΎαβααααβααβααααΆαβααα
|
α£
|
αααααΆα αα‘ ααΊβααΆβαααααΆα αβααΈαα½α αααβααΆαβααβααααβααβααααΆαβααααΈ
|
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