MySQL Forums
Forum List  »  Stored Procedures

DAYNAME problem using CASE statement
Posted by: John Noble
Date: May 07, 2020 06:12AM

Hi folks,

Im having difficulty in determining the dayname on a stored proc.
Here is my proc.

CREATE DEFINER=`root`@`%` PROCEDURE `usp_SalesHistoryFrenchTransportDocsTest`(
IN p_despatchDate date
)
BEGIN

SELECT CASE salesHistory.despatchDate WHEN DAYNAME(p_despatchDate) = "Saturday" THEN
DATE_ADD(salesHistory.despatchDate, INTERVAL 2 DAY)
ELSE
DATE_ADD(salesHistory.despatchDate, INTERVAL 1 DAY) END as despatchDate FROM salesHistory
WHERE saleshistory.despatchDate = p_despatchDate;


END

When I use call usp_SalesHistoryFrenchTransportDocsTest('2020-04-04') (which is a Saturday), I expect the data to add 2 days on to it. But it always adds 1 day. It does not seem to to be catching on the first case statement.

What am I missing here?

J

Options: ReplyQuote


Subject
Views
Written By
Posted
DAYNAME problem using CASE statement
265
May 07, 2020 06:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.