Reputation: 9
I don't have any idea how to do it... I need to skip sundays. My query is like
SELECT * FROM `table_1` WHERE `date`=(CURRENT_DATE + INTERVAL 1 DAY)
but if next day is sunday i need rows from query like this one
SELECT * FROM `table_1` WHERE `date`=(CURRENT_DATE + INTERVAL 2 DAY)
Any ideas will be helpful.
Upvotes: 0
Views: 231
Reputation: 697
You could put case
inside the interval
statement, like:
SELECT * FROM `table_1`
WHERE `date` = (
CURRENT_DATE + INTERVAL (
case when dayofweek(current_date + interval 1 day) = 1 then 2 else 1 end
) DAY
);
Upvotes: 0
Reputation: 48780
You can check if CURRENT_DATE
is Saturday and produce the value accordingly.
For example:
SELECT *
FROM `table_1`
WHERE `date`=
case when dayofweek(current_date) = 7 -- saturday
then CURRENT_DATE + INTERVAL 2 DAY
else CURRENT_DATE + INTERVAL 1 DAY
end
Upvotes: 1