Salman Ahmed
Salman Ahmed

Reputation: 95

query records from the mysql DB in date range but not of Sundays

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

Answers (2)

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115530

SELECT
    t.*
FROM 
    tableX AS t
WHERE 
    t.dateColumn >= CURDATE() - INTERVAL 14 DAY
  AND 
    WEEKDAY(t.dateColumn) <> 6 ;

Upvotes: 0

Farzher
Farzher

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

Related Questions