DateDiff returns the time interval between two dates (such as the minutes)

sponsored links
DateDiff returns the time interval between two dates (such as the minutes)

Back to the time interval between two dates.
Grammar
DateDiff (interval, date1, date2 [, firstdayofweek] [, firstweekofyear]])
DateDiff function syntax has the following parameters:

Parameter Description
interval Required. String expression that is used to calculate the time between date1 and date2 interval. The values, see "Settings" section.
date1, date2 Required. Date of expression. Used to calculate the two dates.
firstdayofweek optional. The first day of the week specified constant. If not specified, the default is Sunday. The values, see "Settings" section.
firstweekofyear optional. The first week of the year specified constant. If not specified, the default location for the January 1st week. The values, see "Settings" section.

Set up
interval parameter can have the following values:
Setting Description
yyyy Year
q Quarterly
m month
y number of days a year
d day
w the number of days a week
ww Week
h-hour ("I have not succeeded with this before, do not know how it is, minute, hour, can not, hope there is to know the friends to help, thank you")
n minutes ("Now a lot of articles online is actually more minutes with m, the right should be n, a small New hereby amended")
s seconds

firstdayofweek parameter can have the following values:

Constants describing
vbUseSystem 0 using regional language support (NLS) API set.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

firstweekofyear parameter can have the following values:

Constants describing
use of regional language support vbUseSystem 0 (NLS) API set.
vbFirstJan1 1 by the Jan. 1 week where the (default).
vbFirstFourDays 2 by the New Year at least four days in the first week.
vbFirstFullWeek 3 in the new year by the first full week.

Explain
DateDiff function is used to determine between the two dates specified number of time intervals. For example, you can use the DateDiff calculation of the number of days difference between two dates, or the day of the year the number of weeks between the last day.
To calculate the difference between date1 and date2 number of days, you can use "the number of days a year" ("y") or "Day" ("d"). When the interval is "the number of days a week" ("w") when, DateDiff returns the number of weeks between two dates. If date1 is Monday, the Monday before date2 DateDiff to calculate the number. This result contains does not contain date2 date1. If the interval is the "Week" ("ww"), the DateDiff function returns the calendar in the number of weeks between two dates. Between date1 and date2 function calculates the number of Sundays. If date2 is Sunday, DateDiff to calculate date2, but even if date1 is Sunday, it will not count date1.

If date1 is later than date2, the DateDiff function returns a negative number.

firstdayofweek parameters will use the "w" and "ww" interval symbols affect the calculation.

If date1 or date2 is a date of writing, is designated the year will be the date of the fixed part. However, if date1 or date2 is included in the quotation marks ("") and omitted in the year, calculated in the code each time date1 or date2 expression, it will insert the current year. This can be written for different years of the program code.

In the interval as the "year" ("yyyy"), the comparison on December 31 and January 1 next year, although in practice only a difference of one day, DateDiff returns 1 indicates a difference of one year.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of DateDiff returns the time interval between two dates (such as the minutes)

  • Rails source code analysis (1): RailsFCGIHandler

    In accordance with the sequence starting from the beginning CGI Ruby CGI Doc: The Common Gateway Interface ( CGI ) Is a simple protocol for passing an HTTP request from a web server to a standalone program, and returning the output to the web browser ...

  • Depth understanding of the eval function in javascript

    http://wanyij.blog.51cto.com/46570/43794 In this paper, the discovery of an appropriate title is not so easy, huh, huh, so in this note under the first two purposes of this article: (1) introduction of the eval function in javascript usage (2) how to func

  • Using Rails Captcha plug-in, easy implementation Verification Code

    Simple Captcha Plugin Can help us easily in the Rails implementation of Verification Code function. In addition, he has the option to provide sufficient to meet the U.S. requirements for certification, the use of easy. Supported picture and digital authen

  • Shoes - Construction Ruby client gadget

    Shoes Ruby are cross-platform GUI applications, recently released a new version, it is a very interesting Ruby GUI client, the following are some characteristics of Introduction: 1. Cross-platform support for windows / linux / mac os 2. Very small, t ...

  • Workspace run under different Eclipse

    Now do live more and more often required to use eclipse in java and ruby & rails project conducted between the tangential shear from the past, because in the rails project used a coloring Aptana preferences, the results open the java project sour ...

  • JS in the Date type conversion

    http://blog.csdn.net/yzy0612/archive/2007/08/07/1730732.aspx

  • Hibernate Inteceptor

    The end of the project stage, the client suddenly put forward a very troublesome but normal demand, the system records all changes must be carried out. Formats such as: 2004.1.1 12:30 Ikuya wind orders Sales Order Date 2004.1.2-> 2004.1.3 The firs ...

  • RoR explained

    ROR is Ruby on Rails. Ruby is a well-known has been very good dynamic language It's dynamic language. Simple and easy. Dynamic languages are interpreted, but the performance may make a discount, but not absolute, because the application is complex, th

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • Ruby on Rails Routing - Simple Examples

    This article contains a list of ruby on rails routing examples. If you find you have any questions please leave a comment. Routes are processed from the top of routes.rb down. If a route is matched it will stop processing the routes.rb file and use that r

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries