DatePart Function

DatePart 関数は、日付の指定された部分を返します。

Syntax:


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:

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

ご支援をお願いします!