Accumulate--datediff functions

Source: Internet
Author: User


When doing the function of the machine, in order to calculate two time difference, need to use a DateDiff function, below to understand this function.


Official explanation:

DateDiff is a time interval that returns between two dates.

Syntax: DateDiff (interval, date1, date2 [, firstdayofweek[, FirstWeekOfYear]])

Parameters Describe
Interval Must be selected. A string expression that is used to calculate the time interval between date1 and date2 . See the Settings section for values.
Date1, Date2 Must be selected. The date expression. The two dates used for the calculation.
FirstDayOfWeek Optional. Constant that specifies the first day of the week. If not specified, the default is Sunday. See the Settings section for values.
FirstWeekOfYear Optional. A constant that specifies the first week of the year. If not specified, the default is the week in which January 1 is located. See the Settings section for values.
interval can have the following values:
Set up Describe
yyyy Years
Q Quarter
M Month
Y Number of days in a year
D Day
W Number of days in a week
Ww Week
H Hours
N Minutes
S Seconds

The following machine calculates how long it takes between the upper and lower machines as an example

' Calculates the time difference Dim time As        Long        Dim time1 As Long        Dim time2 As Long               Dim OT As String = MyList. First.ontime        Dim OD as String = MyList. First.ondate time        =  DateDiff ("n", OD, Today.date) +datediff ("n", OT, TimeOfDay) ' Get a total of how many minutes        Dim Ihour as Integer ' Converts a long type of time to an integer type        ihour = (int (time/60)) ' Long value is beyond the range of Int and then it will be problematic. Is that the transformed value becomes        txtcontime.text = Ihour ' Get hours


This will give you the time to spend on the machine. At the same time, according to the function calculation can also calculate the consumption amount of the machine


Additional: The DateAdd function is similar to its usage, and can be calculated by adding/minus a time interval. Interested in understanding the DATEADD function

This time function is not very difficult, but after the use of the multiplier. Accumulation.



Accumulate--datediff functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.