Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
yipchunyu
Yak Posting Veteran
80 Posts |
Posted - 2003-08-14 : 05:20:24
|
| i want to select records from a table which last processing date less than or equal to (today - 3 working days)I create another tables to store the holiday but don't know how to make use of it. any helps? |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-08-14 : 07:41:44
|
| Actually, i think what is easiest is not a table of holidays, but a table of dates in which the following rule doesn't work:If the day of the week of the date is 2,3, or 4 (mon-wed) --- the start date is 5 days before Otherwise, the start date is 3 days beforeI assume the day of the week will never be 1 or 7 (sun or sat -- that won't make sense. If so, let me know)In your table, store dates in which this won't work. For example, if July 4th is a holiday and is on wednesday, instead of storing 7/4/2003 in a table, store this:Date,ExceptionDayAdd7/5/2003,-6 (i think that's right ....)7/6/2003,-4Thus, you check this table, and if you get a match, use the DateAdd(dd,ExceptionDayAdd,CurrentDate).If you don't get a match, check datepart(dw, CurrentDate): if <5, use DateAdd(dd, -5 ,CurrentDate). Otherwise, use DateAdd(dd,-3,CurrentDate)something like that, anyway .....- Jeff |
 |
|
|
|
|
|
|
|