Funzione DatePart
La funzione DatePart restituisce la parte specificata di una data.
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
Valore restituito:
The extracted part for the given date.
interval - A string expression from the following table, specifying the date interval.
interval (string value)
|
Spiegazione
|
yyyy
|
Anno
|
q
|
Trimestre
|
m
|
Mese
|
y
|
Giorno dell'anno
|
w
|
Giorno della settimana
|
ww
|
Settimana dell'anno
|
d
|
Giorno
|
h
|
Ora
|
n
|
Minuto
|
s
|
Secondo
|
data - La data dalla quale viene calcolato il risultato.
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
|
Spiegazione
|
0
|
Usa il valore predefinito di sistema
|
1
|
Domenica (predefinito)
|
2
|
Lunedì
|
3
|
Martedì
|
4
|
Mercoledì
|
5
|
Giovedì
|
6
|
Venerdì
|
7
|
Sabato
|
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
|
Spiegazione
|
0
|
Usa il valore predefinito di sistema
|
1
|
La settimana 1 è quella che comprende il 1° gennaio (predefinito)
|
2
|
La settimana 1 è la prima settimana che comprende quattro o più giorni di quell'anno
|
3
|
La settimana 1 è la prima settimana che comprende solo giorni del nuovo anno
|
Sub example_datepart
MsgBox DatePart("ww", #12/31/2005#)
MsgBox DatePart(date:=#1999-12-30#, interval:="q")
End Sub