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

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

Back to the time interval between two dates.
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.

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.

分类:Database 时间:2010-06-08 人气:402
blog comments powered by Disqus


  • oracle10g initialization parameter description 2010-04-19

    ref: Parameter name: O7_DICTIONARY_ACCESSIBILITY Category: Security and Audit Description: mainly used for transplantation from Oracle7 to Oracle8i. If the value is TRUE, SYSTEM privilege

  • oracle Parameter Description 2010-10-25

    oracle Parameter Description Oracle database system initialization parameter file init.ora in accordance with the parameters set to configure their own startup, each instance starts, first read the parameter file to set the different parameters. Orac

  • Oracle archive mode command and parameter description 2010-04-03

    Oracle database can run in 2 modes: archive mode (archivelog) and non-archive mode (noarchivelog). Archiving model can enhance the recoverability of Oracle database, production database should be run in this mode, the archive mode and the correspondi

  • bash shell if the command parameter description 2010-06-08

    Conditional statements in Chapter 7 Directory 7.1. Introduced if 7.1.1. Summary 7.1.2. If a simple application 7.2. More if the high use 7.2.1. If / then / else structure 7.2.2. If / then / elif / else structure 7.2.3. If nested statement 7.2.4. Bool

  • MySQL compile Parameter Description 2010-03-24

    Install MySQL / Usr / sbin / groupadd mysql / Usr / sbin / useradd-g mysql mysql tar zxvf mysql-5.4.0-beta.tar.gz cd mysql-5.4.0-beta CFLAGS = "-O6-mpentiumpro-fomit-frame-pointer" CXX = gcc CXXFLAGS = "-O6-mpentiumpro-fomit-frame-pointer-f

  • MySQL Parameter Description 2011-05-16

    MySQL Parameter Description Wikipedia, the free encyclopedia Original Address: 1. Back_log Specify the number of connections MySQL can. When the MySQL main thread in a very s

  • [Reprinted] Java String.Format () method and parameter description 2010-05-15

    JDK1.5 in, String class adds a useful static method String.format (): format (Locale l, String format, Object ... args) using the specified locale, format string and parameter returns a formatted string. format (String format, Object ... args JDK1.5

  • flexigrid for jquery Parameter Description 2010-05-01

    $('#EmployeeGrid').flexigrid({ // The table width ( Note You cannot use the IE 100% The type of string: ) width:$(window).width()-2, // The table height ( Note You cannot use the IE 100% The type of string: ) height:480, // Data columns-color paintin

  • apache log LogFormat parameter description 2010-07-13

    In the apache httpd.conf configuration file in the default configuration so a logformat "% h% l% u% t \"% r \ "%> s% b \"% (Referer) i \ "\"% (User-Agent) i \ "" common This is the APACHE formatting log records,

  • bcdecit Parameter Description 2011-01-05

    Bcdedit located in the X: \ Windows \ system32 \ "X:" drive letter for the installation of Vista. Store operating instructions ==================== / Createstore create a new empty boot configuration data file. bcdedit / createstore C: \ Data \

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.156 (s). 10 q(s)