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.