Rate this:
See more:
in database i have two column from and to date.

from date 5.10.2012
to date 21.11.2012

for that i want to get the difference between two dates.for that i how to write the query in sql server.
Posted 21-Nov-12 1:12am
__TR__ at 21-Nov-12 6:27am

Take a look at DATEDIFF[^] (Transact-SQL)

It varies based on your requirement. Th difference in what ? Days ? Minutes ? Hours?

Rate this:

## Solution 3

difference between two dates get Result in days
`select datediff(d, '2012-10-05' , '2012-11-21')`

Happy Coding!
Rate this:

## Solution 1

Try this Query....

`select datediff(mi, '2012-10-05 15:29:55.090' , '2012-11-21 15:30:09.153')`

OR

`SELECT DATEDIFF(dd,'24 March 1964','24 March 2001')`
v4
Rate this:

## Solution 2

you can try something like below :

`SELECT DATEDIFF(DAY, convert(datetime,'5.10.2012',104),  convert(datetime,'21.11.2012',104)) as Difference`
v2
Rate this:

## Solution 4

You Can Find the diffrence even in nanosecond format!!
Use DATEDIFF Function.