DatePart Function

La función DatePart devuelve una parte concreta d'una fecha.

Syntax:


DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long

Valor de torna:

The extracted part for the given date.

Parameters:

interval - A string expression from the following table, specifying the date 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


date - The date from which the result is calculated.

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

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_datepart
    MsgBox DatePart("ww", #12/31/2005#)
    MsgBox DatePart(date:=#1999-12-30#, interval:="q")
End Sub

Please support us!