AfternoonI have a sproc that generates maildates for records loaded into the database each week day. Depending on the type of letter, each document will be mailed that day, the following month or will have a 2 day delay. I am using a CASE statement to determine how to set the mail date. However, for those with the 2day delay, those that are received on a thursday or a friday will have a mail date that falls on a saturday or sunday, which is not possible. Therefore, I want to treat the 2day delays differently for thursdays and fridays. However, i cannot seem to find a function that returns a character string or integer that represents the specific day of the week.I have tried DAY(GETDATE()), DATENAME(DAY, GETDATE()) but these return the day of the month: 13 as opposed to 'Friday' (or an integer representing friday(depending on what DATEFIRST is set to).Can anyone help?Here is the code for setting the mail date parameter:SET @mailDate = CASE (SELECT Frequency FROM SendFrequency F INNER JOIN LetterCode L ON F.SendFrequencyID = L.SendFrequencyID WHERE LetterCode = @letterCode) WHEN 'Daily' THEN @todaysDate WHEN '2Day Delay' THEN DATEADD(DAY, 2,@todaysDate) WHEN 'Monthly' THEN CASE (SELECT DATEPART(MONTH, @todaysDate)) WHEN 2 THEN '16 March 2005' WHEN 3 THEN '16 April 2005' WHEN 4 THEN '14 May 2005' WHEN 5 THEN '18 June 2005' WHEN 6 THEN '16 July 2005' WHEN 7 THEN '20 August 2005' WHEN 8 THEN '17 September 2005' WHEN 9 THEN '17 October 2005' WHEN 10 THEN '19 November 2005' WHEN 11 THEN '17 December 2005' END END
What I want to say is something like:CASE WHEN @todaysDate ='Thursday' THEN DATEADD(DAY, 4,@mailDate)WHEN @todaysDate ='Friday' THEN DATEADD(DAY, 4,@mailDate)
What function can I use to do the above??Thanks in advanceHearty head pats