Date Range in Query using DateAdd

J

Justin

I have a query set up to search for a specific date range. I have data on
week 12/26/08-01/01/09and that works just fine. I also have data from
01/02/09-01/08/09 and it wont work. It pulls all the data from the table.
Below is the line i use in the criteria:

Between [Enter Start Date] And =DateAdd("d",6,[Enter Start Date])

I have it like that because i do not want the user to be able to accidently
get more then the pay weeks data.
 
J

Justin

Thank you! It let to another issue i am having though. I have a query that
calculates the total hours of someone working for a week. There is a seperate
table that has all the employee information (name, address, bill rate, pay
rate, etc) i need the bill rate into a query but the control source is
EmployeePayroll. How can i get the Bill Rate from EmployeeInformation to the
query i am making with EmployeePayroll as the contorl source?

Al Campagna said:
Justin,
Remove the "=" sign
Between [Enter Start Date] And DateAdd("d",6,[Enter Start Date])
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Justin said:
I have a query set up to search for a specific date range. I have data on
week 12/26/08-01/01/09and that works just fine. I also have data from
01/02/09-01/08/09 and it wont work. It pulls all the data from the table.
Below is the line i use in the criteria:

Between [Enter Start Date] And =DateAdd("d",6,[Enter Start Date])

I have it like that because i do not want the user to be able to
accidently
get more then the pay weeks data.
 
K

Ken Sheridan

Join the EmployeePayroll table to the EmployeeInformation table in the query
on the EmployeeID (or whatever the primary/foreign key columns in the tables
are called). You can then return the Bill Rate as a column in the query's
result table, or you can reference it in an expression in a computed column.

BTW, on a point of terminology, a table is not the 'control source' of the
query. The ControlSource property is, not surprisingly, a property of a
control in a form or report. It can be the name of a column from the
underlying table or query in the case of a bound control, or an expression
which returns a value to be shown in the control in the case of an unbound
control. A query can draw upon one or more tables, which appear in its
SELECT clause in SQL view, or are shown in the top part of the window in
query design view. In the former tables are (usually, though not always)
joined in a JOIN clause (or sometimes in a WHERE clause); in the latter they
are joined by dragging a line from the primary key field of one to the
corresponding foreign key field of the other.

Ken Sheridan
Stafford, England

Justin said:
Thank you! It let to another issue i am having though. I have a query that
calculates the total hours of someone working for a week. There is a seperate
table that has all the employee information (name, address, bill rate, pay
rate, etc) i need the bill rate into a query but the control source is
EmployeePayroll. How can i get the Bill Rate from EmployeeInformation to the
query i am making with EmployeePayroll as the contorl source?

Al Campagna said:
Justin,
Remove the "=" sign
Between [Enter Start Date] And DateAdd("d",6,[Enter Start Date])
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

Justin said:
I have a query set up to search for a specific date range. I have data on
week 12/26/08-01/01/09and that works just fine. I also have data from
01/02/09-01/08/09 and it wont work. It pulls all the data from the table.
Below is the line i use in the criteria:

Between [Enter Start Date] And =DateAdd("d",6,[Enter Start Date])

I have it like that because i do not want the user to be able to
accidently
get more then the pay weeks data.
 
K

Ken Sheridan

Correction: tables appear in the FROM clause of a query, not the SELECT
clause; its columns (fields) which appear in the latter

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

Top