DATEDIFF: return the difference between two dates : DATEDIFF « Date Timezone « SQL Server / T-SQL

Home
SQL Server / T-SQL
1.Aggregate Functions
2.Analytical Functions
3.Constraints
4.Cursor
5.Data Set
6.Data Type
7.Database
8.Date Timezone
9.Index
10.Insert Delete Update
11.Math Functions
12.Select Query
13.Sequence
14.Store Procedure Function
15.String Functions
16.Subquery
17.System
18.Table
19.Table Joins
20.Transact SQL
21.Transaction
22.Trigger
23.View
24.XML
SQL Server / T-SQL » Date Timezone » DATEDIFF 
DATEDIFF: return the difference between two dates

1> -- DATEDIFF: return the difference between two dates.
2>
3> -- DATEDIFF(what_to_return,first_date,second_date)
4>
5> -- Return the number of days between 24th March 1964 and 2001, you would use,
6>
7SELECT DATEDIFF(dd,"24 March 1964","24 March 2001")
8> GO

-----------
      13514

(rows affected)
1>

           
       
Related examples in the same category
1.select DATEDIFF(second, '06:46:45', '11:35:00')
2.select DATEDIFF(quarter, '2001-12-01', '2002-09-30')
3.Find the number of days between 24th March 2001 and 24th March 1964
4.DATEDIFF(yyyy, "24 March 2001","24 March 1964")
5.DATEDIFF(mi, "24 March 2001","24 March 1964")
6.DATEDIFF(wk, "24 March 2001","24 March 1964")
7.DATEDIFF(m, "24 March 2001","24 March 1964")
8.DATEDIFF(d, @thisdate, @nextmonth) 'Days between'
9.DATEDIFF(month, '9-8-1989', '10-17-1991')
10.DATEDIFF(day, '9-8-1989', '10-17-1991')
11.Difference in weeks between 7-2-1996 and 8-4-1997
12.DATEDIFF(ss, @MyBirthDate, GETDATE())
13.select DATEDIFF(hour, '06:46:45', '11:35:00')
14.select DATEDIFF(minute, '06:46:45', '11:35:00')
15.Difference between the current time and UTC
16.DATEDIFF: date difference
17.Combine DateADD and DateDIFF to get the last date of a month
18.Passing a column name to the DATEDIFF() value argument
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.