Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 DateDiff

Author  Topic 

rn5a
Starting Member

25 Posts

Posted - 2008-11-04 : 05:47:16
A table has 2 columns - SDateTime & EDateTime (datatype of both are smalldatetime). One of the records in these 2 columns is 10/01/2008 8:00:00 PM & 10/01/2008 11:30:00 PM respectively. When I run the following query:

SELECT DATEDIFF(mi, SDateTime, EDateTime) FROM MyTable

the output is stragely 210 & not 30. Why?

Thanks,

Ron

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-04 : 05:50:28
quote:
Originally posted by rn5a

A table has 2 columns - SDateTime & EDateTime (datatype of both are smalldatetime). One of the records in these 2 columns is 10/01/2008 8:00:00 PM & 10/01/2008 11:30:00 PM respectively. When I run the following query:

SELECT DATEDIFF(mi, SDateTime, EDateTime) FROM MyTable

the output is stragely 210 & not 30. Why?

Thanks,

Ron


Why do you expect 30?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-11-04 : 05:50:56
quote:
Originally posted by rn5a

A table has 2 columns - SDateTime & EDateTime (datatype of both are smalldatetime). One of the records in these 2 columns is 10/01/2008 8:00:00 PM & 10/01/2008 11:30:00 PM respectively. When I run the following query:

SELECT DATEDIFF(mi, SDateTime, EDateTime) FROM MyTable

the output is stragely 210 & not 30. Why?

Thanks,

Ron



hi,

The above select stmt gives the difference between sdatetime and edatetime columns in terms of Minutes...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-04 : 05:55:23
SELECT DATEDIFF(mi, SDateTime, EDateTime)%60 FROM MyTable

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -