I have a parameter called pmday which I want to, when it is enetered, check if the day is on a saturday or sunday, and, if so, show the monday after.
I am relatively new to mySQL and I am running a SELECT statement to use pmday in other ways. Can I create a column which will show the monday after, only if the day falls on a weekend?
Here is an example of what I have been trying (and failing) to do. Im not sure if this is just a problem of me not knowing how, functions within select statements not being allowed, or general formatting and use of commas.
Thank you!
SELECT
pmday AS EnteredDate,
IF DateFormat(pmday, '%W') = 'Saturday' then
Date_Add('pmday', INTERVAL 2 DAY) AS FollowingMonday
Else If DateFormat(pmday, '%W') = 'Sunday' then
Date_Add('pmday', INTERVAL 1 DAY) AS FollowingMonday
END IF;
1 Answer