![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Sep 2004
Posts: 44
Rep Power: 0
![]() |
MSSQL - Get data between specific week days
Hello:
I need help in how to get data from a table with a daterange from sunday to saturday of the last week. What I'm looking for is to be able to do this any day of the current week. |
|
|
|
|
|
#2 |
|
Not a user?
Join Date: Sep 2007
Posts: 256
Rep Power: 2
![]() |
Re: MSSQL - Get data between specific week days
From the day you're on, just go back to the previous Sunday, make an array of 7 dates, starting at that Sunday, include the next 7 days in your array, see if today is in that array, if it is, go back another Sunday and start again, if it isn't, then you have your week.
|
|
|
|
|
|
#3 |
|
Software Developer
Join Date: Jun 2008
Posts: 4
Rep Power: 0
![]() |
Re: MSSQL - Get data between specific week days
I think you will need something like this:
function GetRowsWeekLeeadingUptoDate($a_Date) {
$a_SevenDaysAgo = $a_Date - days(7);
$l_Sql = "SELECT * FROM table_name WHERE date BETWEEN $a_Date AND $a_SevenDaysAgo;";
$l_Results = mysql_query($l_Sql);
return $l_Results;
}depending on how your storing you dates you will need to convert between the formats to pass to you sql for the BETWEEN part Mike
__________________
There are 10 kinds of people in this world....Those who understand binary and those who don't. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Jun 2007
Posts: 99
Rep Power: 2
![]() |
Re: MSSQL - Get data between specific week days
on that note i had real headaches working with time based queries, it's easier to use a timestamp and convert your times from that.
|
|
|
|
|
|
#5 | |
|
Software Developer
Join Date: Jun 2008
Posts: 4
Rep Power: 0
![]() |
Re: MSSQL - Get data between specific week days
Quote:
its a shame that sort of thing isnt built into the php5_mysql module, or is it? Mike
__________________
There are 10 kinds of people in this world....Those who understand binary and those who don't. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question regarding data input into PHP/Mysql using something other than GET | davil | PHP | 6 | Nov 20th, 2007 8:06 AM |
| caluculate day of week given present date and number of days | srinivasc_it | C++ | 4 | Nov 4th, 2006 4:54 AM |
| convert unarrenged .txt data to arrange .txt data | pastalover | Visual Basic | 2 | Jun 23rd, 2006 4:22 PM |
| Recommended Practice for returning data from function | Arla | C# | 1 | Aug 16th, 2005 12:21 PM |
| help with sockets, having a client recieve data as well as send. | cypherkronis | Python | 7 | Jul 1st, 2005 5:59 PM |