Time subtraction in VB

Source: Internet
Author: User

When I was working on the data center charging system, I encountered a problem, that is, how to calculate the time difference between the time when the machine was running and the time when the machine was down.

The following occurs:

The time difference between the machine and the machine is as long as two days. How can we calculate the time difference. The datediff () function is used.

DateDiff (timeinterval, date1, date2 [, firstdayofweek [, firstweekofyear])

Allowed data type: timeinterval indicates the time interval type. The code is:

Year yy, yyyy quarter qq, q

Month mm, m

Dy, y

Date dd, d

Week wk, ww

Dw on weekdays

Hour hh

Min mi, n

Ss, s

Millisecond MS

For example

? DateDiff ("M", "2000-9-1", "2002-2-1") 17

However, I found that when this system is applied to schools, it will not allow students to go to the computer all night. How can this problem be solved? tomorrow or the day after tomorrow. In this case, forced dismounting is used. Force students to go offline at a fixed time in the evening. Ensure that the machine is on the same day and the machine is off on the same day. Think about the principle of overnight connection with Internet cafes. At a.m., members are allowed to go offline or switch to overnight connections. Program Design really comes from life...

In this case, we only need to reduce the time of the server. It is easier to subtract the Time of the server. Only apply

Format (#7:12:45 PM #-#5:23:34 PM #, "HH: mm: SS.

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.