Employee Name & Hours Worked for The Day

Hi all,

I'm trying to determine the name and time that employees work on a certain day. So I'd like to see the employee name next to the hour of the day like this:

Name, TimeIn, TimeOut Yvonne, 11, 15

select c.name, datepart([hour], t.TimeIn) as TimeIn, datepart([hour], t.TimeOut) as TimeOut

--select c.name, t.timein, timeout from cashier c, timeclock t where t.cashierID = c.id and convert(varchar(10),t.DBTimeStamp,110) = '05-05-2008'

I have trouble with the date convert me thinks. Not too familiar with date format conversions in SQL Server.

Any suggestions?

Reply to
Jerry
Loading thread data ...

Hi Jerry -

Can something like this work for you?

select c.name, datepart([hour], t.TimeIn) as Hour_TimeIn, datepart([hour], t.TimeOut) as Hour_TimeOut from cashier c inner join timeclock t on c.id = t.cashierid where t.timein between '1/3/2008' and '1/4/2008'

-- this would show you at what hour clock ins and clock outs took place (for january 3 2008) -- hope this helps....

"Jerry" wrote:

Reply to
convoluted

Try it without converting the datatype....you'll get date and hr/min on both the clock in and the clock out - hope this helps.....

select c.name, t.Time> > > Hi Jerry -

Reply to
convoluted

OK - try it this way - though I split it into two columns since I'm not sure how to "cut off" the minutes/seconds from the datetime datatype...maybe a more experienced SQL user will post that solution for you with a "right trim"

- hope this helps....

select c.name, convert(char(11),t.timein) as DateIn, datepart([hour], t.TimeIn) as Hour_TimeIn, convert(char(11),t.timeout)as DateOut, datepart([hour], t.TimeOut) as Hour_TimeOut from cashier c inner join timeclock t on c.id = t.cashierid where t.timein between '1/3/2008' and '1/4/2008'

"Jerry" wrote:

datepart([hour],

Reply to
convoluted

BeanSmart website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.