Función DatePart
La función DatePart devuelve una parte concreta de una fecha.
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
Valor de retorno:
The extracted part for the given date.
 interval - A string expression from the following table, specifying the date interval.
  
    | interval (string value) | Explicación | 
  
    | yyyy | Año | 
  
    | q | Trimestre | 
  
    | m | Mes | 
  
    | y | Día del año | 
  
    | w | Día de la semana | 
  
    | ww | Semana del año | 
  
    | d | Día | 
  
    | h | Hora | 
  
    | n | Minuto | 
  
    | s | Segundo | 
 
 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:
    - 
        #yyyy-mm-dd# 
- 
        #mm/dd/yyyy# 
 
 firstdayofweek: An optional parameter that specifies the starting day of a week.
  
    | firstdayofweek value | Explicación | 
  
    | 0 | Utilizar valor predeterminado del sistema | 
  
    | 1 | Sunday (valor predeterminado) | 
  
    | 2 | Lunes | 
  
    | 3 | Martes | 
  
    | 4 | Miércoles | 
  
    | 5 | Jueves | 
  
    | 6 | Viernes | 
  
    | 7 | Sábado | 
 firstweekofyear: An optional parameter that specifies the starting week of a year.
  
    | firstweekofyear value | Explicación | 
  
    | 0 | Utilizar valor predeterminado del sistema | 
  
    | 1 | Week 1 es la semana del día 1 de enero (predeterminado) | 
  
    | 2 | Week 1 es la primera semana que contiene cuatro o más días de ese año | 
  
    | 3 | Week 1 es la primera semana que únicamente contiene días del año nuevo | 
 
Sub example_datepart
    MsgBox DatePart("ww", #01/02/2005#) ' displays 2 because weeks start on Sunday
    MsgBox DatePart("ww", #12/31/2005#) ' displays 53
    MsgBox DatePart(date:=#2005-12-30#, interval:="q") ' displays 4
End Sub