You would want your sort field to be an integer that corresponds to day of the week:
1 = Monday
2 = Tuesday
3 = Wednesday
...
Without more specifics, it is hard to give you a code sample. If your weekday is stored as varchar, I suggest that you create a database scalar function that takes day of week as a string argument and returns the appropriate integer.
Here is a sample in T-SQL:
create function dbo.GetDayNumber (
@dayOfWeek varchar(9)
) returns tinyint
as begin
declare @dayNum tinyint
set @dayNum = 0
select @dayNum =
case
when @dayOfWeek = 'Monday' then 1
when @dayOfWeek = 'Tuesday' then 2
when @dayOfWeek = 'Wednesday' then 3
when @dayOfWeek = 'Thursday' then 4
when @dayOfWeek = 'Friday' then 5
when @dayOfWeek = 'Saturday' then 6
when @dayOfWeek = 'Sunday' then 7
end
return @dayNum
end
Be careful - the above code returns 0 for invalid day names, which could screw with your results if your data is not perfect.
select
MyEvent,
DayOfWeek
from MyEventTable
order by dbo.GetDayNumber(DayOfWeek)