Funci贸 DateDiff

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

Sintaxi:


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

Valor de retorn:

Un n煤mero.

Par脿metres :

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

interval (string value)

Explicaci贸

yyyy

Any

q

Trimestre

m

Mes

y

Dia de l'any

w

Dia feiner

ww

Setmana de l'any

d

Dia

h

Hora

n

Minut

s

Segon


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

Explicaci贸

0

Utilitza el valor per defecte del sistema

1

Diumenge (per defecte)

2

Dilluns

3

Dimarts

4

Dimecres

5

Dijous

6

Divendres

7

Dissabte


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

firstweekofyear value

Explicaci贸

0

Utilitza el valor per defecte del sistema

1

La setmana 1 茅s la setmana de l'1 de gener (per defecte)

2

La setmana 1 茅s la primera setmana que cont茅 quatre dies o m茅s d'aquell any

3

La setmana 1 茅s la primera setmana que nom茅s cont茅 dies de l'any nou


Exemple :


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

Ens cal la vostra ajuda!