Conteníu
Índiz 🔎︎

# 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

## Valor de torna:

un númberu.

### Parameters:

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

interval (string value) | Esplicación
--- | ---
yyyy | Añu
q | Trimestre
m | Mes
y | Día del añu
w | Día de la selmana
ww | Selmana del añu
d | Día
h | Hora
n | Minutu
s | Segundu

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:

- #yyyy-mm-dd#

- #mm/dd/yyyy#

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

firstdayofweek value | Esplicación
--- | ---
0 | Utilizar valor predetermináu del sistema
1 | Domingu (valor predetermináu)
2 | Llunes
3 | Martes
4 | Miércoles
5 | Xueves
6 | Vienres
7 | Sábadu

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

firstweekofyear value | Esplicación
--- | ---
0 | Utilizar valor predetermináu del sistema
1 | Week 1 ye la selmana del día 1 de xineru (predetermináu)
2 | Week 1 ye la primer selmana que contién cuatro o más díes d'esi añu
3 | Week 1 ye la primer selmana que namái contién díes del añu nuevu

### Example:

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