DatePart Function

អនុគមន៍ DatePart ត្រឡប់​ផ្នែក​នៃ​កាលបរិច្ឆេទ​ដែលបាន​បញ្ជាក់ ។

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:

firstdayofweek: An optional parameter that specifies the starting day of a week.

firstdayofweek value

សេចក្តី​ពន្យល់

ប្រើ​តម្លៃ​លំនាំដើម​ប្រព័ន្ធ

ថ្ងៃ​អាទិត្យ (លំនាំដើម)

ថ្ងៃ​ច័ន្ទ

ថ្ងៃ​អង្គារ

ថ្ងៃ​ពុធ

ថ្ងៃ​ព្រហស្បតិ៍

សុក្រ

សៅរ៍


firstweekofyear: An optional parameter that specifies the starting week of a year.

firstweekofyear value

សេចក្តី​ពន្យល់

ប្រើ​តម្លៃ​លំនាំដើម​ប្រព័ន្ធ

សប្ដាហ៍១ គឺ​ជា​សប្ដាហ៍​ដែល​មាន ថ្ងៃ​ទី១ ខែ​មករា (លំនាំដើម)

សប្ដាហ៍១ គឺ​ជា​សប្ដាហ៍​ទីមួយ ដែល​មាន​បួន ឬ​ច្រើន​ថ្ងៃ​នៃ​ឆ្នាំ​នោះ

សប្ដាហ៍១ គឺ​ជា​សប្ដាហ៍​ទីមួយ ដែល​មាន​តែ​ថ្ងៃ​នៃ​ឆ្នាំ​ថ្មី


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