sanctified
Programmer
Hi Group,
Currently, I have a Stored Procedure which is called from my ASP Page. It takes into account Fridays and weekends passing the value in as a parameter:
snippet....
if @pListType = 'F' -- being a Friday
begin
SELECT su.SuspensionID, su.ConsentNo, si.SiteID,
si.NameNo + ' ' + si.Address1 AS SiteAddress, si.SiteDesc,
si.SuspensionStart, si.SuspensionEnd, si.Address1, si.BaysAttached, rd.RefValue AS NoticeDays, si.MergeID
FROM Suspension su
INNER JOIN SiteData si ON su.SuspensionID = si.SuspensionID
INNER JOIN RefData rd ON si.NotReq = rd.RefCode
WHERE su.Status = 'ACT'
and si.Archived = 'N'
and (datediff(day, getdate(), si.SuspensionStart) = rd.RefValue
or datediff(day, getdate(), si.SuspensionStart) = rd.RefValue + 1
or datediff(day, getdate(), si.SuspensionStart) = rd.RefValue + 2)
end
The above is saying where the day is a Friday and the difference between the current date and the suspension date = the notice period (rd.refvalue) OR the difference between the current date and the suspension date = the notice period plus 1 or 2 days (to take into account Saturday and Sunday)print the signs. I need to incorporate holiday dates into this routine.
For the UK Bank Holiday which just passed (29th May), I fudged it by using the following code:
If substring(cast(getdate() as varchar),1,11) = 'May 26 2006'
begin
SELECT su.SuspensionID, su.ConsentNo, si.SiteID,
si.NameNo + ' ' + si.Address1 AS SiteAddress, si.SiteDesc,
si.SuspensionStart, si.SuspensionEnd, si.Address1, si.BaysAttached,
rd.RefValue AS NoticeDays, si.MergeID
FROM Suspension su
INNER JOIN SiteData si ON su.SuspensionID = si.SuspensionID
INNER JOIN RefData rd ON si.NotReq = rd.RefCode
WHERE su.Status = 'ACT'
and si.Archived = 'N'
and (datediff(day, getdate(), si.SuspensionStart) = rd.RefValue
or (si.SuspensionStart = '05/06/2006'
end
these needed to go out on Friday 26th May...
Firstly I will need to take into account the day of the week for the holiday. I have created a table called tblHolidayDates with a field called Holiday_Date.
I'm a bit confused on how to implement it/call my table from within the SP. Once I have this, I will know how to code the remainder.
Any pointers much appreciated.
Currently, I have a Stored Procedure which is called from my ASP Page. It takes into account Fridays and weekends passing the value in as a parameter:
snippet....
if @pListType = 'F' -- being a Friday
begin
SELECT su.SuspensionID, su.ConsentNo, si.SiteID,
si.NameNo + ' ' + si.Address1 AS SiteAddress, si.SiteDesc,
si.SuspensionStart, si.SuspensionEnd, si.Address1, si.BaysAttached, rd.RefValue AS NoticeDays, si.MergeID
FROM Suspension su
INNER JOIN SiteData si ON su.SuspensionID = si.SuspensionID
INNER JOIN RefData rd ON si.NotReq = rd.RefCode
WHERE su.Status = 'ACT'
and si.Archived = 'N'
and (datediff(day, getdate(), si.SuspensionStart) = rd.RefValue
or datediff(day, getdate(), si.SuspensionStart) = rd.RefValue + 1
or datediff(day, getdate(), si.SuspensionStart) = rd.RefValue + 2)
end
The above is saying where the day is a Friday and the difference between the current date and the suspension date = the notice period (rd.refvalue) OR the difference between the current date and the suspension date = the notice period plus 1 or 2 days (to take into account Saturday and Sunday)print the signs. I need to incorporate holiday dates into this routine.
For the UK Bank Holiday which just passed (29th May), I fudged it by using the following code:
If substring(cast(getdate() as varchar),1,11) = 'May 26 2006'
begin
SELECT su.SuspensionID, su.ConsentNo, si.SiteID,
si.NameNo + ' ' + si.Address1 AS SiteAddress, si.SiteDesc,
si.SuspensionStart, si.SuspensionEnd, si.Address1, si.BaysAttached,
rd.RefValue AS NoticeDays, si.MergeID
FROM Suspension su
INNER JOIN SiteData si ON su.SuspensionID = si.SuspensionID
INNER JOIN RefData rd ON si.NotReq = rd.RefCode
WHERE su.Status = 'ACT'
and si.Archived = 'N'
and (datediff(day, getdate(), si.SuspensionStart) = rd.RefValue
or (si.SuspensionStart = '05/06/2006'
end
these needed to go out on Friday 26th May...
Firstly I will need to take into account the day of the week for the holiday. I have created a table called tblHolidayDates with a field called Holiday_Date.
I'm a bit confused on how to implement it/call my table from within the SP. Once I have this, I will know how to code the remainder.
Any pointers much appreciated.