Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialManish Barik
Courses Plus Student 4,058 PointsHow 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
Full Stack JavaScript Techdegree Student 15,373 PointsTry 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");
Manish Barik
Courses Plus Student 4,058 PointsManish Barik
Courses Plus Student 4,058 PointsI want sql to automatically detect the date. Will this work:
SELECT COUNT(*) FROM blogs WHERE scheduled_for BETWEEN getdate() AND getdate("+6 days");
Andrew Wong
Full Stack JavaScript Techdegree Student 15,373 PointsAndrew Wong
Full Stack JavaScript Techdegree Student 15,373 PointsI have edited the answer. Is that what you're looking for?