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

Návratová hodnota:

Číslo.

Parameters:

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

interval (string value)

Vysvetlenie

yyyy

Rok

q

Štvrtina

m

Mesiac

y

Deň v mesiaci

w

Pracobný deň

ww

Týždeň v roku

d

Deň

h

Hodina

n

Minúta

s

Sekunda


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

Vysvetlenie

0

Použiť prednastavenú systémovú hodnotu

1

Nedeľa (prednastavená hodnota)

2

Pondelok

3

Utorok

4

Streda

5

Štvrtok

6

Piatok

7

Sobota


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

firstweekofyear value

Vysvetlenie

0

Použiť prednastavenú systémovú hodnotu

1

Týždeň 1 je týždeň, ktorý obsahuje 1. január (prednastavená hodnota)

2

Týždeň 1 je prvý týždeň obsahujúci 4 alebo viac dní tohto roka

3

Týždeň 1 je prvý týždeň obsahujúci iba dni tohto roka


Example:


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

Please support us!