Back to the time interval between two dates.
DateDiff (interval, date1, date2 [, firstdayofweek] [, firstweekofyear]])
DateDiff function syntax has the following parameters:
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.
interval parameter can have the following values:
y number of days a year
w the number of days a 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")
firstdayofweek parameter can have the following values:
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:
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.
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.
Related Posts of DateDiff returns the time interval between two dates (such as the minutes)
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 ...
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 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 ...
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 ...
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 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 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 ...
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