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)
 Check Time Duration

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2009-09-25 : 11:24:46
Dear All,

I have two columns In_Time & Out_Time

In_Time - Out_Time
10:34 AM - 08:00 PM

now i have to capture that how much hr is in between 10:00 to : 06:00 from above In_Time and Out_Time



jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-09-25 : 12:32:49
This will calculate the hours between 10AM and 8PM based on the info you provided

SELECT DATEDIFF(hour,CONVERT(datetime,'10:34 AM'), CONVERT(datetime,'08:00 PM'))

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2009-09-25 : 12:42:22
Example : I have login 08:00 PM and Logout at 05:00 AM not i have to capture that how much hour he has worked between 10:00 PM to 06:00 AM in this case answer should be 7 hrs.
Another Example if login time is 09:30 PM and Login Out Time is 08:00 AM then answer will be 8 hrs.

Hope you got what i want
Go to Top of Page
   

- Advertisement -