Find inbetween date

J

jwinsten

I'm trying to write a query to see if someone worked duplicated hours
during a day. The query will take the person and match it to all hours
worked during that wee with a start time and end time. If on the next
time they have hours for any of the hours that person already entered
it will return with the two records. I'm not sure how to write this
one.

Here is what I have so far.
SELECT
(CASE WHEN endtime<= 24 THEN DATEADD(hour, endtime, shiftdate)
when endtime> 24 then dateadd (hour, endtime, shiftdate)
when shiftend <> 0 then DATEADD([hour], shiftend,shiftdate) END) AS
[end time],
dbo.SCHEDULE.ShiftDate,endtime,
(CASE WHEN starttime <= 24 THEN DATEADD(hour, starttime, shiftdate)
when starttime > 24 then dateadd (hour, starttime, shiftdate)
when fshiftstart <> 0 then DATEADD(hour, fshiftstart,shiftdate) END) AS
[start time]
,dbo.SHIFTTYPES.ShiftEnd, dbo.ACTIVESHIFTS.fShiftStart,
dbo.SCHEDULE.StartTime as [mod start time], dbo.SCHEDULE.EndTime
as [mod end time], dbo.SCHEDULE.ModifiedHours

FROM dbo.ACTIVESHIFTS INNER JOIN
dbo.SCHEDULE ON dbo.ACTIVESHIFTS.ActiveShiftID =
dbo.SCHEDULE.ShiftNum INNER JOIN
dbo.SCHEDULESETUP ON dbo.SCHEDULE.ScheduleID =
dbo.SCHEDULESETUP.ScheduleID INNER JOIN
dbo.SHIFTTYPES ON dbo.SCHEDULESETUP.UnitNum =
dbo.SHIFTTYPES.UnitNum AND
dbo.SHIFTTYPES.ScheduleNum =
dbo.SCHEDULESETUP.ScheduleID INNER JOIN
dbo.SHIFT ON dbo.ACTIVESHIFTS.ShiftNum =
dbo.SHIFT.ShiftNum AND dbo.SHIFTTYPES.[Index] = dbo.SHIFT.ShiftType AND

dbo.SHIFTTYPES.ScheduleNum =
dbo.SCHEDULESETUP.ScheduleID INNER JOIN
dbo.PARAM ON dbo.SHIFT.CostCenter =
dbo.PARAM.ParamID INNER JOIN
dbo.UNITS ON dbo.SCHEDULESETUP.UnitNum =
dbo.UNITS.UNITNUM INNER JOIN
dbo.STAFF ON dbo.SCHEDULE.StaffNum =
dbo.STAFF.UserNum

WHERE dbo.ACTIVESHIFTS.dtmSchedStart > 1 / 1 / 2006
ORDER BY shiftDate ASC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top