MySQL select all dates that are an increment of x days

date, mysql, sql

Solution

Something like:

SELECT
     *
FROM table
WHERE
    date >= CURDATE()
    AND
    DATEDIFF(CURDATE(), date) % 6 = 0

Datediff returns the number of days difference, and `% 6` says return the remainder when divided by six.

Problem

Is it possible to query for all dates in the future that are an increment of x days? i.e. ``` SELECT * FROM bookings WHERE date >= CURDATE() AND ( date = CURDATE() + INTERVAL 6 DAY OR date = CURDATE() + INTERVAL 12 DAY OR date = CURDATE() + INTERVAL 18 DAY etc. ) ```

Original source