Querying the day of the week

G

Guest

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?
 
G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top