Poddy Posted June 28, 2008 Share Posted June 28, 2008 i want my results to show only from the current week as in sunday to sunday... is this possible? thanks in advance Quote Link to comment Share on other sites More sharing options...
webent Posted June 28, 2008 Share Posted June 28, 2008 Yes, it is possible... You'll need to build a bit of a function for it... I believe there are several examples like what you want on the php site, www.php.net/date Quote Link to comment Share on other sites More sharing options...
br0ken Posted June 30, 2008 Share Posted June 30, 2008 You can compare dates in MySQL so yes, this is possible. Quote Link to comment Share on other sites More sharing options...
fenway Posted July 2, 2008 Share Posted July 2, 2008 You can compare dates in MySQL so yes, this is possible. That's right -- you know what day of the week it is now, so you can easily subtract/add the difference to sunday. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2008 Share Posted July 2, 2008 Untested but should work - SELECT your_columns FROM your_table WHERE WEEK(your_date,mode) = WEEK(CURDATE(),mode) AND YEAR(your_date) = YEAR(CURDATE()) Check the mysql manual for the "mode" value to use in the above query to match your definition of what a week is. Edit: Here is an even shorter version (it pays to read a little further down in the manual) - SELECT your_columns FROM your_table WHERE YEARWEEK(your_date,mode) = YEARWEEK(CURDATE(),mode) The "mode" value in YEARWEEK() is the same as you picked for the WEEK() function. Quote Link to comment Share on other sites More sharing options...
Poddy Posted July 5, 2008 Author Share Posted July 5, 2008 Untested but should work - SELECT your_columns FROM your_table WHERE WEEK(your_date,mode) = WEEK(CURDATE(),mode) AND YEAR(your_date) = YEAR(CURDATE()) Check the mysql manual for the "mode" value to use in the above query to match your definition of what a week is. Edit: Here is an even shorter version (it pays to read a little further down in the manual) - SELECT your_columns FROM your_table WHERE YEARWEEK(your_date,mode) = YEARWEEK(CURDATE(),mode) The "mode" value in YEARWEEK() is the same as you picked for the WEEK() function. thanks for the replys, but one thing i still do not understand, i need to select the CURRENT week so if i replace your_date with CURDATE it would just input the same result.. how will that work... what am i supposed to put in "your_date" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.