P
Purny
Using Access 2003
Brendan Reynolds said:Here's an example from one of my own apps ...
SELECT tblStudents.LastName, tblStudents.FirstName,
tblStudents.MiddleName, tblStudents.DOB, tblStudents.Room, tblYear.YrName,
tblTeachers.TeacherName
FROM tblTeachers RIGHT JOIN (tblStudents LEFT JOIN tblYear ON
tblStudents.YearNum = tblYear.YrNo) ON tblTeachers.TeacherID =
tblStudents.TeacherID
WHERE (((tblStudents.Dleft) Is Null) AND ((Month([DOB]))=Month(Date()))
AND ((Day([DOB]))=Day(Date()))) OR (((tblStudents.Dleft)>Date()) AND
((Month([DOB]))=Month(Date())) AND ((Day([DOB]))=Day(Date())));
'DLeft' is the date the student left the school, so in addition to the DOB
field, the above query also checks that the DLeft field is either Null or
contains a date that is in the future.
--
Brendan Reynolds
Access MVP
Purny said:Using Access 2003
Douglas J. Steele said:Just curious, Brendan. Why not
WHERE (tblStudents.Dleft Is Null OR tblStudents.Dleft > Date())
AND (Format([DOB], "mmdd") Format(Date(), "mmdd")
or even
WHERE Nz(tblStudents.Dleft, Date() + 1) > Date())
AND (Format([DOB], "mmdd") Format(Date(), "mmdd")
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Brendan Reynolds said:Here's an example from one of my own apps ...
SELECT tblStudents.LastName, tblStudents.FirstName,
tblStudents.MiddleName, tblStudents.DOB, tblStudents.Room,
tblYear.YrName, tblTeachers.TeacherName
FROM tblTeachers RIGHT JOIN (tblStudents LEFT JOIN tblYear ON
tblStudents.YearNum = tblYear.YrNo) ON tblTeachers.TeacherID =
tblStudents.TeacherID
WHERE (((tblStudents.Dleft) Is Null) AND ((Month([DOB]))=Month(Date()))
AND ((Day([DOB]))=Day(Date()))) OR (((tblStudents.Dleft)>Date()) AND
((Month([DOB]))=Month(Date())) AND ((Day([DOB]))=Day(Date())));
'DLeft' is the date the student left the school, so in addition to the
DOB field, the above query also checks that the DLeft field is either
Null or contains a date that is in the future.
--
Brendan Reynolds
Access MVP
Purny said:Using Access 2003
Brendan Reynolds said:It's years since I wrote that, Doug, so I really couldn't say whether
there was any specific reason why I chose that approach rather than one of
the alternatives. And I'm not entirely sure that I ever did write it
exactly as it now appears - I think Access may have rearranged it
somewhat. Do you think it makes a significant difference?
--
Brendan Reynolds
Access MVP
Douglas J. Steele said:Just curious, Brendan. Why not
WHERE (tblStudents.Dleft Is Null OR tblStudents.Dleft > Date())
AND (Format([DOB], "mmdd") Format(Date(), "mmdd")
or even
WHERE Nz(tblStudents.Dleft, Date() + 1) > Date())
AND (Format([DOB], "mmdd") Format(Date(), "mmdd")
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Brendan Reynolds said:Here's an example from one of my own apps ...
SELECT tblStudents.LastName, tblStudents.FirstName,
tblStudents.MiddleName, tblStudents.DOB, tblStudents.Room,
tblYear.YrName, tblTeachers.TeacherName
FROM tblTeachers RIGHT JOIN (tblStudents LEFT JOIN tblYear ON
tblStudents.YearNum = tblYear.YrNo) ON tblTeachers.TeacherID =
tblStudents.TeacherID
WHERE (((tblStudents.Dleft) Is Null) AND ((Month([DOB]))=Month(Date()))
AND ((Day([DOB]))=Day(Date()))) OR (((tblStudents.Dleft)>Date()) AND
((Month([DOB]))=Month(Date())) AND ((Day([DOB]))=Day(Date())));
'DLeft' is the date the student left the school, so in addition to the
DOB field, the above query also checks that the DLeft field is either
Null or contains a date that is in the future.
--
Brendan Reynolds
Access MVP
Using Access 2003
To be honest, I don't know. It strikes me that
(Format([DOB], "mmdd") = Format(Date(), "mmdd"))
is going to be more efficient than
(Month([DOB]))=Month(Date()) AND (Day([DOB])=Day(Date())
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.