zdJRM‖

rUz5H‖DateDiff Function

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

FVEx2‖Syntax:


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

BPDH8‖Return value:

BXncY‖A number.

WADQ4‖Parameters:

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

yKYH5‖interval (string value)

BrkDy‖Explanation

QCaFK‖yyyy

uCMGD‖Year

BTQbh‖q

aAbFF‖Quarter

khy6d‖m

DnwYQ‖Month

2kcLi‖y

5ceAL‖Day of year

gDYqD‖w

zMz7B‖Weekday

SGGGX‖ww

Wknbt‖Week of year

AodTF‖d

QUMAr‖Day

DtMSq‖h

bW8VY‖Hour

EFdrN‖n

E7sMZ‖Minute

gpxE5‖s

saACB‖Second


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

5FGDA‖Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:

hjbSu‖ firstdayofweek: An optional parameter that specifies the starting day of a week.

wpCoP‖firstdayofweek value

gmaR8‖Explanation

A5RkW‖0

Xt9Xx‖Use system default value

6UMdD‖1

uV8iz‖Sunday (default)

zuFMX‖2

vUz3C‖Monday

2YAp3‖3

KCW5A‖Tuesday

8rkEA‖4

hhEsB‖Wednesday

3F47C‖5

Zv7Dn‖Thursday

aP5Bd‖6

EbThD‖Friday

CmnqZ‖7

BjBfG‖Saturday


UFDDA‖ firstweekofyear: An optional parameter that specifies the starting week of a year.

e3gQd‖firstweekofyear value

zAFFS‖Explanation

XEzpc‖0

jXczC‖Use system default value

sqUf8‖1

65vhA‖Week 1 is the week with January, 1st (default)

7KXnC‖2

wFZe8‖Week 1 is the first week containing four or more days of that year

85UKo‖3

xAkGk‖Week 1 is the first week containing only days of the new year


EFSA4‖Example:


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