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
|
āĻŦā§āϝāĻžāĻā§āϝāĻž
|
0
|
āϏāĻŋāϏā§āĻā§āĻŽā§āϰ āĻĄāĻŋāĻĢāϞā§āĻ āĻŽāĻžāύ āĻŦā§āϝāĻŦāĻšā§āϤ āĻšā§
|
1
|
āϰāĻŦāĻŋāĻŦāĻžāϰ (āĻĄāĻŋāĻĢāϞā§āĻ)
|
2
|
āϏā§āĻŽāĻŦāĻžāϰ
|
3
|
āĻŽāĻā§āĻāϞāĻŦāĻžāϰ
|
4
|
āĻŦā§āϧāĻŦāĻžāϰ
|
5
|
āĻŦā§āĻšāϏā§āĻĒāϤāĻŋāĻŦāĻžāϰ
|
6
|
āĻļā§āĻā§āϰāĻŦāĻžāϰ
|
7
|
āĻļāύāĻŋāĻŦāĻžāϰ
|
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
|
āĻŦā§āϝāĻžāĻā§āϝāĻž
|
0
|
āϏāĻŋāϏā§āĻā§āĻŽā§āϰ āĻĄāĻŋāĻĢāϞā§āĻ āĻŽāĻžāύ āĻŦā§āϝāĻŦāĻšā§āϤ āĻšā§
|
1
|
āĻŦāĻāϰā§āϰ ā§§āĻŽ āϏāĻĒā§āϤāĻžāĻšāĻāĻŋ āĻšāϞ⧠⧧āϞāĻž āĻāĻžāύā§ā§āĻžāϰāĻŋ āϏāĻŽā§āĻŦāϞāĻŋāϤ āϏāĻĒā§āϤāĻžāĻš (āĻĄāĻŋāĻĢāϞā§āĻ)
|
2
|
āϏāĻĒā§āϤāĻžāĻš ā§§ āĻšāϞ⧠āϏā§āĻ āĻŦāĻāϰā§āϰ āĻāĻžāϰ āĻ
āĻĨāĻŦāĻž āϤāϤā§āϧāĻŋāĻ āĻĻāĻŋāύ āĻŦāĻŋāĻļāĻŋāώā§āĻ āĻĒā§āϰāĻĨāĻŽ āϏāĻĒā§āϤāĻžāĻš
|
3
|
āϏāĻĒā§āϤāĻžāĻš ā§§ āĻšāϞ⧠āύāϤā§āύ āĻŦāĻāϰā§āϰ āĻļā§āϧā§āĻŽāĻžāϤā§āϰ āĻĻāĻŋāύ āĻŦāĻŋāĻļāĻŋāώā§āĻ āĻĒā§āϰāĻĨāĻŽ āϏāĻĒā§āϤāĻžāĻš
|
Sub example_datepart
MsgBox DatePart("ww", #12/31/2005#)
MsgBox DatePart(date:=#1999-12-30#, interval:="q")
End Sub