Funktion DateDiff

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

RĂźckgabewert:

Eine Zahl.

Parameter:

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

interval (string value)

Erklärung

yyyy

Jahr

q

Quartal

m

Monat

y

Kalendertag

w

Wochentag

ww

Kalenderwoche

d

Tag

h

Stunde

n

Minute

s

Sekunde


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

Erklärung

0

Systemvorgabewert verwenden

1

Sonntag (Vorgabe)

2

Montag

3

Dienstag

4

Mittwoch

5

Donnerstag

6

Freitag

7

Samstag


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

firstweekofyear value

Erklärung

0

Systemvorgabewert verwenden

1

Woche 1 ist die Woche, auf die der 1. Januar fällt. (Vorgabe)

2

Woche 1 ist die erste Woche, die mindestens vier Tage dieses Jahres enthält

3

Woche 1 ist die erste Woche, die ausschließlich Tage dieses Jahres enthält


Beispiel:


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