Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datediff

Status
Not open for further replies.

annub

Programmer
Apr 23, 2003
33
US
I want to get in and out time for each emp for each day.
My data is somthing like this.
id seq Date Time tothrs
5058 1 6/30/2003 7:13:00 AM 713 null
5058 2 6/30/2003 0 0 null
5058 1 6/16/2003 7:02:00 AM 702 null
5058 2 6/16/2003 3:28:00 PM 1528 null
5058 1 6/17/2003 6:57:00 AM 657 null
5058 2 6/17/2003 3:30:00 PM 1530 null
5058 1 6/18/2003 7:20:00 AM 720 null

I want to update tothrs col with actual hrs for each employee on a single day from date col. for ex : on 6/17 i shoulg get 8 hrs in tothrs col. i am not sure how do i update each records for each diff employees.

Thanks for all your help
Ann
 
try this!
suppose your table name is temp

select a.id, convert(varchar(10), a.[date], 101),
datediff(mi,a.date, b.date) / 60
from temp a
inner join
temp b
on a.id = b.id
and convert(varchar(10), a.[date], 101) = convert(varchar(10), b.[date], 101)
and a.seq < b.seq
hope this will help.
meydz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top