Exclude records based on the day of the week name (e.g. Monday)

S

Silvio

Objective: Employees that are scheduled to be off today should be excluded
from the list of available.

I have 1 table with 2 text fields EmployeeName and DayOff. The DayOff field
has one of the days of the week in it (e.g. Monday). I managed to extract the
name of the day of the week fro today’s date, however I am having trouble to
compare the two field in the query in order to exclude record where the name
in the two filed are equal (DayOff<>DayWeek).

This is what I have:
SELECT tblEmployees.Name, tblEmployees.DayOff, Format(Date(),"dddd") AS
DayWeek
FROM tblEmployees;

Thank you folks.
 
J

Jeff Boyce

It sounds like you want to see the Employee where DayOff is <> Today's "Day
of the Week".

Your SQL statement has no WHERE clause.

Your SQL statement has no way to determine Today's "Day of the Week" for
comparison purposes.

Have you tried using the query design view to do this, rather than in SQL?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

Silvio

I did but it does not work.

Jeff Boyce said:
It sounds like you want to see the Employee where DayOff is <> Today's "Day
of the Week".

Your SQL statement has no WHERE clause.

Your SQL statement has no way to determine Today's "Day of the Week" for
comparison purposes.

Have you tried using the query design view to do this, rather than in SQL?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

KARL DEWEY

Try this --
SELECT tblEmployees.Name, tblEmployees.DayOff, Format(Date(),"dddd") AS
DayWeek
FROM tblEmployees
WHERE tblEmployees.DayOff <> Format(Date(),"dddd");
 
S

Silvio

Karl, thanks a lot this works just fine.

KARL DEWEY said:
Try this --
SELECT tblEmployees.Name, tblEmployees.DayOff, Format(Date(),"dddd") AS
DayWeek
FROM tblEmployees
WHERE tblEmployees.DayOff <> Format(Date(),"dddd");
 
J

John W. Vinson

Objective: Employees that are scheduled to be off today should be excluded
from the list of available.

I have 1 table with 2 text fields EmployeeName and DayOff. The DayOff field
has one of the days of the week in it (e.g. Monday). I managed to extract the
name of the day of the week fro today’s date, however I am having trouble to
compare the two field in the query in order to exclude record where the name
in the two filed are equal (DayOff<>DayWeek).

It might be simpler if your DayOff field were an integer, 1 (Sunday) through 7
(Saturday), though you can use the name of the day if you prefer. I take it
employees only get one day off a week? Never two? (Wouldn't want to work
there!!!)

That said...

SELECT tblEmployees.Name
FROM tblEmployees
WHERE tblEmployees.DayOff <> Format(Date()), "dddd");
 
J

Jeff Boyce

"does not work" doesn't give us much to go on.

The query design view works just fine for my queries ... what's it doing on
yours?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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

Top