So, where do I put the SQL?

G

Guest

I have the following SQL, stolen from another site, I wish to use to find
employee anniversary dates for the next year.

SELECT LastName, FirstName, HireDate, IIF(DateSerial(Year(Date() + 1,
Month(HireDate), Day(HireDate)) < Date() + 365, Year(Date() + 60) –
Year(HireDate), Year(Date()) – Year(HireDate))
AS YearsOfService
FROM tblEmployees
WHERE (DateSerial(Year(Date()), Month(HireDate), Day(HireDate))
BETWEEN Date() AND Date()) + 365 OR (DateSerial(Year(Date()) + 1,
Month(HireDate), Day(HireDate)) <= Date() + 365;


So, where do I put this?
 
G

Guest

Hi,

First modify the SQL below to match all your table and field names exactly.
If any of your names have spaces in them, you need to surround them with [].
FirstName is OK below; however you need [First Name].

Next open up a new query in design mode. When the table window pops up, just
close it without adding any tables. Next go up to View and select SQL View.
Past in the SQL and run it. As a Select statement it will usually do one of
three things: (1) Work!, (2) not work because something is wrong with the
table or field names or datatypes; or (3) you might have a references
problems as functions like Date() are used in the SQL.
 

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