I have the following stored procedure:
SELECT
moncallAdd.FirstListing,
DATEADD(MINUTE, mOnCallAdd.StartOnCallTime,
DATEADD(DAY, mOnCallAdd.StartOnCallDate, '12/31/1899')) AS OnCallStart,
DATEADD(MINUTE, mOnCallAdd.duration,
DATEADD(MINUTE, mOnCallAdd.StartOnCallTime,
DATEADD(DAY, mOnCallAdd.StartOnCallDate, '12/31/1899'))) AS OnCallEnd,
'Added' As Activity
FROM
mdr.dbo.mOnCallAdd
WHERE DATEADD(MINUTE, mOnCallAdd.StartOnCallTime,
DATEADD(DAY, mOnCallAdd.StartOnCallDate, '12/31/1899'))
BETWEEN Convert(VARCHAR(10), GetDate(), 101) AND GetDate() and
mOnCallAdd.SchedName = @schedname
UNION
SELECT
moncallDelete.FirstListing,
DATEADD(MINUTE, mOnCallDelete.StartOnCallTime,
DATEADD(DAY, mOnCallDelete.StartOnCallDate, '12/31/1899')) AS OnCallStart,
DATEADD(MINUTE, mOnCallDelete.duration,
DATEADD(MINUTE, mOnCallDelete.StartOnCallTime,
DATEADD(DAY, mOnCallDelete.StartOnCallDate, '12/31/1899'))) AS OnCallEnd,
'Deleted' as Activity
FROM
mdr.dbo.mOnCallDelete
WHERE DATEADD(MINUTE, mOnCallDelete.StartOnCallTime,
DATEADD(DAY, mOnCallDelete.StartOnCallDate, '12/31/1899'))
BETWEEN Convert(VARCHAR(10), GetDate(), 101) AND GetDate() and
mOnCallDelete.SchedName = @schedname
and what this query currently does is to return back values for oncallstart up and including the current time for anything that matches a schedname and what I'm needing to do is as follows:
Search for OnCallEnddate past todays date that has a OncallStartime before the current time, and also that shows only "added" as activity.
Can anyone offer a way to do that? Thank you
Doug