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!