DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
戻り値:
The extracted part for the given date.
Parameters:
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
Week 1 は 1 月 1 日を含む週 (デフォルト)
2
Week 1 は、その年の 4 日以上を含む最初の週
3
Week 1 は、新年の日付のみを含む最初の週
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