Databases Reporting with SQL Date and Time Functions Calculating Dates

How do I show next week in SQL, i,e. starting from coming Sunday to the following Saturday?

I would like to show blog posts scheduled next week. How do I get SQL consider that?

1 Answer

Andrew Wong
Andrew Wong
Full Stack JavaScript Techdegree Student 15,373 Points

Try using:

BETWEEN DATE("now") AND DATE("now", "+6 days");

So, if your table is titled "blogs" and the dates are in a column titled "scheduled_for"..

SELECT COUNT(*) FROM blogs WHERE scheduled_for BETWEEN DATE("now") AND DATE("now", "+6 days");

I want sql to automatically detect the date. Will this work:

SELECT COUNT(*) FROM blogs WHERE scheduled_for BETWEEN getdate() AND getdate("+6 days");