Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Cristian Glodeanu
4,031 PointsLoans Due solution
Hi,
The Loans Due practice question was nice. I've researched and came up with this:
SELECT * FROM loans WHERE return_by BETWEEN DATE('now', 'weekday 0', '-6 days') AND DATE('now', 'weekday 0') AND returned_on IS null;
Did anybody found a cleaner/more compact solution? :)
Cheers!
9 Answers

Denny Schouten
8,244 PointsHi this is my solution SELECT * FROM loans WHERE STRFTIME("%W", return_by) = STRFTIME("%W", "now") AND returned_on IS NULL;

Tee Abdul
8,411 PointsSELECT * FROM loans WHERE return_by BETWEEN DATE("now") AND DATE("now", "+7 days") AND returned_on IS NULL;

Alexandru Palita
14,258 PointsSELECT * FROM loans WHERE returned_on > return_by OR returned_on IS NULL;
:))))

Sean Flanagan
33,232 PointsHow's mine?
SELECT * FROM loans WHERE return_by BETWEEN DATE("now", "+1 week") AND returned_on IS NULL;

Yassin Chiguer
5,228 Pointsselect * from loans where return_by BETWEEN DATE("now", "+ 7days") and returned_on is null

DeAndre' McDade
2,937 PointsSELECT *
FROM loans
WHERE return_by BETWEEN DATE('now', 'weekday 0') AND DATE('now', 'weekday 0', "+6 days")
AND returned_on IS NULL
;

Prashant Parmar
1,621 PointsI believe I have the most compact code!
SELECT * FROM loans WHERE STRFTIME("%w", return_by) AND returned_on IS NULL (optional)
Surprisingly was one of my first attempts at the question :)

Roger Dailey
14,887 PointsThis is how I wrote it: SELECT * FROM loans WHERE return_by BETWEEN DATE("now", "-1 day") AND DATE("now", "+6 days") AND returned_on IS NULL;
When I completed this it was the week of 02/13/17 through 02/19/17 and the day I completed it on was 02/14/17.

Jonatan Spahn
6,362 PointsI did this on today so 3/23 and this is how I did it.
SELECT * FROM loans WHERE return_by BETWEEN DATE("now", "-7 days") AND DATE("now", "+1 days");