The realization of computer room toll system use the DATEDIFF function to calculate the time difference between two dates

Source: Internet
Author: User
Tags date1 time interval

Computer room charges to do on the machine and the next part, the need to calculate from the machine to the time difference between the machine, so as to calculate the costs incurred during the machine.

At this time, you can use a function can be simple to implement--datediff (), the specific use of rules:

DateDiff (Timeinterval,date1,date2 [, FirstDayOfWeek [, FirstWeekOfYear]])

The return value of the function is the time elapsed from Date1 to Date2, timeinterval the type that represents the time interval (that is, the unit of measure of Time), respectively:

Year yyyy

Quarter Q

Month m

One day of the year Y

Date D

Week WW

Hour h

Min n

Seconds s

Millisecond MS

An example is provided:

Example: DateDiff ("Q", #1991 -01-01#, #1992 -01-01#) returns 4

DateDiff ("yyyy", #1991 -01-01#, #2000 -01-01#) returns 9

DateDiff ("n", #06:00:00#, #07:05:04#) return 65

DateDiff ("H", #06:00:00#, #07:05:04#) return 1

......

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/vb/

Related Article

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.