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 2008 Forums
 Transact-SQL (2008)
 Time diffrence

Author  Topic 

vipinjha123
Starting Member

45 Posts

Posted - 2012-06-05 : 03:58:09
Dear Friend,
i have a table attendence table
having 2 column in_date,out_date
i need exact time diffrence of both table
suppose
indate-2012-05-03 08:57:05.000
oudate-2012-05-03 20:12:42.297
which giving me 12hrs
but actual time diffrence is 11 hrs 15 min

plese help me to get exact time diffrnce

regards,
Vipin jha

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-05 : 04:32:49
outdate-indate

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-05 : 10:32:31
[code]
SELECT CONVERT(varchar(8),DATEADD(ss,DATEDIFF(ss,in_date,out_date),0),108) FROM table
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-05 : 10:54:23
what's wrong with SELECT in_date - out_date FROM table

Do yoou want it to the nearest minute, 15 minutes, server precision?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -