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

འགྲལེལ་བཤད།

0

གནས་གོང་སྔོན་སྒྲིག་རིམ་ལུགས་ལག་ལེན་འཐབ།

1

ཟླ་བ (སྔོན་སྒྲིག)

2

མིག་དམར།

3

ལྷག་པ།

4

ཕུར་བུ།

5

པ་སངས།

6

སྤེན་པ།

7

ཉི་མ།


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

firstweekofyear value

འགྲལེལ་བཤད།

0

གནས་གོང་སྔོན་སྒྲིག་རིམ་ལུགས་ལག་ལེན་འཐབ།

1

བདུན་ཕྲག་ ༡་ འདི་སྤྱི་ཟླ་དང་པ་ ༡་ དང་ཅིག་ཁར་བདུན་ཕྲག་༡་པ་ཨིན (default)

2

བདུན་ཕྲག་ ༡་ འདི་ཉིནམ་བཞི་ཡོད་པའི་བདུན་ཕྲག་དང་པ་ཡང་ན་ལོ་འདིའི་ཉིནམ་ལྷགཔ་ཨིན།

3

བདུན་ཕྲག་ ༡་ འདི་ལོ་གསརཔ་གི་ཉིནམ་རྐྱངམ་ཅིག་ཡོད་པའི་བདུན་ཕྲག་དང་པ་ཨིན།


Example:


Sub example_datediff
    MsgBox DateDiff("d", #1/1/2005#, #2005-12-31#)
End Sub

Please support us!