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:

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", #12/31/2005#)
    MsgBox DatePart(date:=#1999-12-30#, interval:="q")
End Sub

Пожалуйста, поддержите нас!