PP
CREATE TABLE #Test (wid INT NOT NULL PRIMARY KEY,
week_day CHAR(3), value BIT NOT NULL)
INSERT INTO #Test VALUES (1,'Mon',0)
INSERT INTO #Test VALUES(2,'Tue',0)
INSERT INTO #Test VALUES(3,'Wed',0)
INSERT INTO #Test VALUES(4,'Thu',0)
INSERT INTO #Test VALUES(5,'Fri',0)
INSERT INTO #Test VALUES(6,'Sat',0)
INSERT INTO #Test VALUES(7,'Sun',0)
SELECT * FROM #Test
UPDATE #Test SET value =1 WHERE wid=(SELECT wid=wid+1 FROM #Test
WHERE week_day=LEFT(DATENAME(WEEKDAY, getdate()),3))
[quoted text, click to view] "PP" <paul@bobbob.net> wrote in message
news:1156306525.177642.109850@i42g2000cwa.googlegroups.com...
> Hi,
>
> I have a table containing 7 fields, Mon, Tues, Wed,Thur,Frid,Sat and
> Sub, all bit types. I need to workout the next run date based on the
> above fields having a value of 1, example:
>
> Today is Wed 24/08/2005
>
> Mon =1, Tue =0, Wed=0, Thurs=0, Frid=0, Sat=0 and Sunday=0
>
> What is the simplest way to work out the date based on the above.
>
> Thanks in advance
> Paul.
>