If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Calculating Time Difference between two different dates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-11, 07:07
manisha21 manisha21 is offline
Registered User
 
Join Date: Nov 2011
Posts: 20
Calculating Time Difference between two different dates

Hi all,

I have data in which i need to calculate employees working hours for a day...
name time in_out
manisha 2011-01-01 9:30:00.000am 1
manisha 2011-01-01 10:30:00.000 0
manisha 2011-01-01 10:45:00.000 1
manisha 2011-01-02 1:00:00.000am 0


how can i calculate time in that two dates as 1 is for entry an 0 is for exit..
please give me solution ASAP.... its urgent
Reply With Quote
  #2 (permalink)  
Old 12-09-11, 11:10
randirsa randirsa is offline
Registered User
 
Join Date: Nov 2011
Posts: 21
This Query may help you to get total time for each employee on particular date.

Select CONVERT(varchar(8), [time], 112) as [Date],name,DATEDIFF(hh,min(time),max(time)) from difftest group by name ,CONVERT(varchar(8), [time], 112)
Reply With Quote
  #3 (permalink)  
Old 12-12-11, 01:12
manisha21 manisha21 is offline
Registered User
 
Join Date: Nov 2011
Posts: 20
hi

Hi its working for only for same date..but according to my question i need time between 2 different dates..means tht person come on one day and went on next day.....

How i can calculate tht time??
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On