I'm working on an older scheduler system whose database was poorly designed.
The system keeps the information by number of the week of the year and number of day of the week (pretty weird):
weekno * weekday * start * end * type * user
20091 1 780 1050 8 99
20091 2 450 720 8 99
20091 4 480 720 8 99
20091 5 450 720 8 99
20092 1 780 1050 8 99
20092 2 450 720 8 99
[All fields are of type Int]
There is a function that returns the data in a more standard format:
Array
(
[0] => Array
(
[id] => 22725
[name] => Aaron G
[date] => 2009-01-01
[sched_in] => 8:00
[sched_out] => 12:00
)
and this function uses a query that looks like this:
SELECT *
FROM timetable
WHERE
user = '99'
AND
weekno BETWEEN '20091' AND '200913'
and of course it returns the data for weeks with numbers like 200841-200851 since these numbers are between 20091 AND 200913
I know how to work around the problem if I'm searching only for dates in a specific year:
SELECT *
FROM timetable
WHERE
user = '99'
AND
weekno BETWEEN '20091' AND '200913'
AND
CONVERT(weekno, CHAR) LIKE '2009%'
but what about when I need something in between 20084 and 200910?
any ideas?
Any help will be really appreciated.