I'm writing a SQL query on a timesheet report. I need the report to return only the details for the week of the selected date.
E.g., if I pick 02/01/2012 (dd/MM/yyyy), then it should only return results between 02/01/2012 and 08/01/2012.
SELECT * FROM yourTable WHERE dateField >= @yourDate AND dateField < @yourDate + 7
Some variations of SQL may have specific ways of adding 7 days to a datevalue. Such as...
DateAdd(Day, 7, @date)
DATE_ADD(@date, INTERVAL 7 DAYS)
- etc, etc
This option is both index friendly, and is resilient to database fields that have time parts as well as date parts.