Reputation: 40621
can I somehow (without using PHP) find nearest previous date of day in week?
Like:
What is date of nearest previous tuesday?
Upvotes: 1
Views: 1045
Reputation: 10635
CURDATE() - INTERVAL WEEKDAY( CURDATE() ) - wday +
IF( WEEKDAY( CURDATE() ) > wday, 0, 7 ) DAY
wday
is the weekday you want ( 0 Monday, 1 Tuesday, ... )
for the same weekday as today this returns today itself, if you want it to return previous week's day change >
to >=
.
Upvotes: 2