Discussion Locked

SQL Server 2000-Compensate For Weekends

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Here is my problem:
I have a date: date1 I want my page to show an alert when today's date is 1 day after date1, along with some other parameters. I am using a SQL Server 2000 view to accomplish all of the filtering on the backend since there are going to be multiple instances like this on my web page, thus the overhead is too large for ASP.

I need my SQL query(View) to compensate for weekends. In other words if date1 is a Friday, I don't want the alert on Saturday, I want it to wait until Monday to alert me. Is there some sort of Aggregate or Scalar function in SQL that I can use to take care of this problem in my query? Or, does anyone have a better idea how to solve this problem. Thanks for your help.

Bob Gibilaro, Web Developer, V. Alexander & Co., Inc.

3 replies

by bojidar alexandrov

/* Here is an example to do this */
use pubs

Select stor_id, ord_date, DateName(weekday,ord_date) as Day_of_ord_date,
alert_date =
CASE
WHEN DateName(weekday,ord_date)='Friday' THEN DateAdd(day,3,ord_date)
WHEN DateName(weekday,ord_date)='Saturday' THEN DateAdd(day,2,ord_date)
ELSE DateAdd(day,1,ord_date)
END
From sales

This discussion is closed to new replies.