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 2000 Forums
 Transact-SQL (2000)
 date difference

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-09-20 : 08:29:12
Manjunath writes "If i have 2 times say 1:30 and 4:30. I want difference of these two times in minutes. What is query or example query to do that......"

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-09-20 : 08:36:26
Declare @startTime nvarchar(10), @endTime nvarchar(10)

Set @startTime = '1:30'
Set @endTime = '4:30'

Select datediff(mi,'09/20/2004 '+@starttime,'09/20/2004 '+@endTime)

Corey
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-09-20 : 09:39:19
or use datetime data type:

Declare @startTime datetime, @endTime datetime

Set @startTime = '1:30'
Set @endTime = '4:30'

Select datediff(minute, @starttime, @endTime)

Kristen
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-09-20 : 10:06:01
i wasn't sure if it would accept only a time string... thats good to know...

Corey
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-09-20 : 14:05:17
SQL chucks in 01-Jan-1900 to make it a full datetime ...

Kristen
Go to Top of Page
   

- Advertisement -