Funktion DatePart
Die Funktion "DatePart" liefert einen bestimmten Teil eines Datums.
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
RĂźckgabewert:
The extracted part for the given date.
interval - A string expression from the following table, specifying the date interval.
interval (string value)
|
Erklärung
|
yyyy
|
Jahr
|
q
|
Quartal
|
m
|
Monat
|
y
|
Kalendertag
|
w
|
Wochentag
|
ww
|
Kalenderwoche
|
d
|
Tag
|
h
|
Stunde
|
n
|
Minute
|
s
|
Sekunde
|
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
|
Erklärung
|
0
|
Systemvorgabewert verwenden
|
1
|
Sonntag (Vorgabe)
|
2
|
Montag
|
3
|
Dienstag
|
4
|
Mittwoch
|
5
|
Donnerstag
|
6
|
Freitag
|
7
|
Samstag
|
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
|
Erklärung
|
0
|
Systemvorgabewert verwenden
|
1
|
Woche 1 ist die Woche, auf die der 1. Januar fällt. (Vorgabe)
|
2
|
Woche 1 ist die erste Woche, die mindestens vier Tage dieses Jahres enthält
|
3
|
Woche 1 ist die erste Woche, die ausschlieĂlich Tage dieses Jahres enthält
|
Sub example_datepart
MsgBox DatePart("ww", #12/31/2005#)
MsgBox DatePart(date:=#1999-12-30#, interval:="q")
End Sub