Web Report for advertisements in the past week - need to identify weekdays vs weekends (Full Version)

All Forums >> [Management Products] >> Microsoft Systems Management Server >> Web Reporting



Message


tbiggi -> Web Report for advertisements in the past week - need to identify weekdays vs weekends (6/4/2008 11:47:50 AM)

Here is a report that shows advertisments with a start date within the past seven days.

The query for the report is:

select distinct PresentTime as AdvertisementStartTime,
OfferID as AdvertisementID,
OfferName as AdvertisementName,
PkgID
from dbo.vOfferStatusSummarizerRoot
where PresentTime >= (GETDATE() - 7)
order by PresentTime Desc

and it is setup with a link (drill down) to report 111 (Status of a specific advertisment).

For those reports within the past seven days we create and send out status reports on day 1, day 3 and day 5 after the start day.  This will eventually be tied in with a SQL job to automatically generate the report and email it out but I only want that to occur on weekdays and not on weekends.  The challenge is to determine if that day 1,2 or 3 falls on a weekend day and if it does, pick the next weekday.

How can that be accomplished in TSQL or WSQL (I'd like to add the Day 1/3/5 days/dates to the web report as well)?





jnelson993 -> RE: Web Report for advertisements in the past week - need to identify weekdays vs weekends (6/4/2008 7:13:34 PM)

Well, in WQL...I don't know if you can, but in SQL you can use DATEPART and look for days between 2 (monday) and 6 (friday)

This will only return "Today is a weekday" if it actually is a weekday today.  Otherwise there will be no records returned.
SELECT
  'Today is a weekday'
WHERE
  DATEPART(WEEKDAY,getDate()) BETWEEN 2 AND 6


This will only return "Today is a weekend" if it actually is a weekend today.  Otherwise no records.
SELECT
  'Today is a weekend'
WHERE
  DATEPART(WEEKDAY,getDate()) IN (1,7)





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.34375