Reputation: 95
Hello I want to query a MySQL database in a date range for last 14 days. And not of Sundays.
The table contains a column with 'Date' datatype.
Please Help.
Upvotes: 0
Views: 227
Reputation: 115530
SELECT
t.*
FROM
tableX AS t
WHERE
t.dateColumn >= CURDATE() - INTERVAL 14 DAY
AND
WEEKDAY(t.dateColumn) <> 6 ;
Upvotes: 0
Reputation: 14563
WHERE DATEDIFF(CURDATE(), table.date) <= 14
AND WEEKDAY(table.date) != 6 #6 is sunday
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
Upvotes: 1