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)
 How to add time and calculate the Waiting time

Author  Topic 

TMDOSS
Starting Member

33 Posts

Posted - 2008-11-20 : 11:05:56
I have table with Date and Slotid
(2008-11-20) and slotid = 1
(I have another table where slot id 1 = 7.00AM
2 = 7.30am ext)
My problem is now I need to find current datetime - date and slot id time from the tabel I have
for Example
if current time is
(2008-11-20 11.01 am) - (2008-11-20) & (Time is based on the slot id if slotid is 1 = 7.00 am)
so i need to get answer 03.01 as time difference
Pl Help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-20 : 11:24:55
try like this
SELECT DATEDIFF(mi,CAST(t1.Date AS varchar(11)) +' '+ CAST(t2.time AS varchar(4)),GETDATE())/60.0 AS TimeDiff
FROM table1 t1
JOIN table2 t2
ON t1.slotid=t2.slotid
Go to Top of Page
   

- Advertisement -