The magical functions of built-in function DateDiff

Source: Internet
Author: User
Tags current time functions time interval
VB has many built-in functions are very practical, very good, this article on the DateDiff to introduce!

1, function functions:

Returns the time interval between two dates.

Example:

DateDiff("D", now, thedate)

D stands for Day (day) now is the current time, Thedate is a time we define ourselves

The result of the entire function, then, is the difference in date between the custom time and the current time.

(By the way will be commonly used to enumerate, s seconds, M minutes, H hours, D-day, N-month, y-year)

Based on this function, we're going to make a release time that shows how long ago the effect

<%

Limit=datediff ("s", "2009-1-17 9:05:35", "2009-1-17 10:05:55")
Response. Write limit& "Seconds"
Response. Write ("
if (limit <) then show_t = "just"
if (limit >= and limit < 3600) Then show_t = INT (LIMIT/60) & "Minutes Ago"
if (limit >= 3600 and limit < 86400) then show_t = INT (limit/3600) & "Hours Ago"
if (limit >= 86400 and limit < 2592000) then show_t = INT (limit/86400) & "Days Ago"
if (limit >= 2592000 and limit < 31104000) then show_t = INT (limit/2592000) & "months ago"
If limit >= 31104000 then show_t = "long time ago ... A big gray wolf ... "
Response. Write (show_t)
%>



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.