DatePart fonksiyonu tarihin belirlenen bir bölümünü döndürür.
Sözdizimi:
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
Dönen değer:
The extracted part for the given date.
Parametreler:
interval - A string expression from the following table, specifying the date interval.
interval (string value)
Açıklama
yyyy
Yıl
q
Çeyrek
m
Ay
y
Yılın günü
w
İş günü
ww
Yılın haftası
d
Gün
h
Saat
n
Dakika
s
Saniye
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
Açıklama
0
Sistem varsayılan değerini kullan
1
Pazar (varsayılan)
2
Pazartesi
3
Salı
4
Çarşamba
5
Perşembe
6
Cuma
7
Cumartesi
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
Açıklama
0
Sistem varsayılan değerini kullan
1
Hafta 1 Ocak ayının haftasıdır, 1inci (varsayılan)
2
Hafta 1 yılın dört veya daha fazla gününü içeren ilk haftasıdır
3
Hafta 1 sadece yeni yılın günlerini içeren ilk haftadır
Örnek:
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