Jason94
Jason94

Reputation: 13620

Select data where date is this week?

How can I limit my SQL to contain data only for this week? (monday to sunday)

Thought of:

SELECT * FROM log WHERE timestamp >= timestamp - INTERVAL 7 DAY && DAYOFWEEK(timestamp-INTERVAL 7 DAY) > 2

But something is not right...

Upvotes: 0

Views: 174

Answers (1)

juergen d
juergen d

Reputation: 204924

SELECT * FROM log 
WHERE yearweek(curdate()) = yearweek(timestamp)

YEARWEEK

Upvotes: 1

Related Questions