The DatePart function returns a specified part of a date.
Syntax:
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
मान फर्काउनुहोस्:
The extracted part for the given date.
Parameters:
interval - A string expression from the following table, specifying the date interval.
interval (string value)
वर्णन
yyyy
वर्ष
q
चौथाई
m
महिना
y
वर्षको दिन
w
हप्ताको दिन
ww
वर्षको हप्ता
d
दिन
h
घण्टा
n
मिनट
s
दोस्रो
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
वर्णन
0
पूर्वनर्धारित मान प्रणाली प्रयोग गर्नुहोस्
1
आइतबार (पूर्वनिर्धारित)
2
सोमबार
3
मंगलबार
4
बुधबार
5
विहीवार
6
शुक्रबार
7
शनिबार
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
वर्णन
0
पूर्वनर्धारित मान प्रणाली प्रयोग गर्नुहोस्
1
पहिलो हप्ता भनेको जनवरीको पहिलो हो, पहिलो (पूर्वनिर्धारित)
2
पहिलो हप्ता, त्यो वर्षको चार वा धेरै दिनहरू समावेश भएको पहिलो हप्ता हो
3
पहिलो हप्ता नयाँ वर्षको दिनहरू मात्र समावेश भएको पहिलो हप्ता हो
Example:
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