Querying the day of the week

B

Brucear

nI want to query the day of the week (Monday, Tuesday..) for today's date and
then retireve the classes I teach from my table on that day of the week.
I have stored the day as Monday = 1, so Monday, period 1 is stored as 11,
Tuesday period 3 is stored as 23. Can anyone advise?
 
K

Ken Sheridan

Bruce:

Try something like this. I've assumed the field in question (which I've
called Period for this example) always contains two digits. The WEEKDAY
function's second argument specifies the starting day for the week, Sunday
being the default, so using 2 means a Monday returns 1, a Tuesday 2 etc, thus
equating with your day numbering.

SELECT *
FROM Classes
WHERE INT(Period/10) = WEEKDAY(DATE(),2);

Ken Sheridan
Stafford, England
 
B

Brucear

Thank you so much!
--
Bruce Rae


Ken Sheridan said:
Bruce:

Try something like this. I've assumed the field in question (which I've
called Period for this example) always contains two digits. The WEEKDAY
function's second argument specifies the starting day for the week, Sunday
being the default, so using 2 means a Monday returns 1, a Tuesday 2 etc, thus
equating with your day numbering.

SELECT *
FROM Classes
WHERE INT(Period/10) = WEEKDAY(DATE(),2);

Ken Sheridan
Stafford, England
 
Top