DateDiff Function

Returns the number of date or time intervals between two given date values.

Syntax:


DateDiff (interval As String, date1 As Date, date2 As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Double

តម្លៃ​ត្រឡប់ ៖

ចំនួន​មួយ ។

Parameters:

interval - A string expression from the following table, specifying the date or time interval.

interval (string value)

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

yyyy

ឆ្នាំ

q

មួយ​ភាគ​បួន

m

ខែ

y

ថ្ងៃ​នៃ​ឆ្នាំ

w

ថ្ងៃ​ធ្វើការ

ww

សប្ដាហ៍​នៃ​ឆ្នាំ

d

ថ្ងៃ

h

ម៉ោង

n

នាទី

s

វិនាទី


date1, date2 - The two date values to be compared.

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_datediff
    MsgBox DateDiff("d", #1/1/2005#, #2005-12-31#)
End Sub