DateDiff Function

Returns the number of date or time intervals between two given date values.

Syntax:

DateDiff (interval As String, date1 As Date, date2 As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Double

반환 값:

숫자

Parameters:

interval - A string expression from the following table, specifying the date or time interval.

interval (string value)

설명

yyyy

연도

q

분기

m

y

w

요일

ww

d

날짜

h

n

s


date1, date2 - The two date values to be compared.

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일이 포함된 주(기본값)가 주 1입니다.

2

해당 연도의 4일 이상이 포함된 첫째 주가 주 1입니다.

3

새로운 연도의 날짜만 포함된 첫째 주가 주 1입니다.


Example:

Sub example_datediff
    MsgBox DateDiff("d", #1/1/2005#, #2005-12-31#)
End Sub

Please support us!