user3818592
user3818592

Reputation: 163

how to query mysql on the current week?

This is my query for the current day:

SELECT COUNT(*) FROM blog_posts WHERE postStatus = "pending" AND DATE(date_accepted) = CURDATE()

now how about if I want to query for this week? Thanks in advance..

Upvotes: 7

Views: 9010

Answers (1)

Barmar
Barmar

Reputation: 780724

Use the YEARWEEK() function

WHERE YEARWEEK(date_accepted) = YEARWEEK(NOW())

Don't just use WEEK() because that will match weeks from different years.

Upvotes: 14

Related Questions