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 Link to comment https://forums.phpfreaks.com/topic/112344-choosing-the-current-week/ 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 Link to comment https://forums.phpfreaks.com/topic/112344-choosing-the-current-week/#findComment-576966 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. Link to comment https://forums.phpfreaks.com/topic/112344-choosing-the-current-week/#findComment-578658 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. Link to comment https://forums.phpfreaks.com/topic/112344-choosing-the-current-week/#findComment-579920 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. Link to comment https://forums.phpfreaks.com/topic/112344-choosing-the-current-week/#findComment-579952 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" Link to comment https://forums.phpfreaks.com/topic/112344-choosing-the-current-week/#findComment-582220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.