Contido
Índice 🔎︎

# Función DateDiff

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

### Sintaxe:

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

## Valor de retorno:

Un número.

### Parámetros:

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

interval (string value) | Explicación
--- | ---
yyyy | Ano
q | Trimestre
m | Mes
y | Día do ano
w | Día da semana
ww | Semana do ano
d | Día
h | Hora
n | Minuto
s | Segundo

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 | Explicación
--- | ---
0 | Usar o valor predeterminado do sistema
1 | Domingo (predefinido)
2 | Luns
3 | Martes
4 | Mércores
5 | Xoves
6 | Venres
7 | Sábado

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

firstweekofyear value | Explicación
--- | ---
0 | Usar o valor predeterminado do sistema
1 | Semana 1 é a primeira semana de xaneiro (predefinido)
2 | Semana 1 é a primeira semana que contén catro días ou máis do ano en curso
3 | Semana 1 é a primeira semana que só contén días do novo ano.

### Exemplo:

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