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
Тиждень 1 - тиждень, який містить 1 січня (типово)
2
Тиждень 1 - перший тиждень, в якому міститься не менше чотирьох днів цього року
3
Тиждень 1 - перший тиждень, у якому містяться лише дні нового року
Приклад:
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