PC Review


Reply
Thread Tools Rate Thread

Dates from a Table in Query

 
 
Larry
Guest
Posts: n/a
 
      10th Nov 2008
I have a simple time tracking database that I am creating. I have a table
tblPayPeriod that just has two columns in it - StartDate and EndDate.

I want to create criteria in the query that will only pull data from between
the two dates, so I have tried to add this to the criteria:

Between [Tables]![tblPayPeriod].[StartDate] And
[Tables]![tblPayPeriod].[EndDate]

But it is not working, HELP!
 
Reply With Quote
 
 
 
 
Duane Hookom
Guest
Posts: n/a
 
      10th Nov 2008
tblPayPeriod would need to be in the "FROM " clause of your query. You
should then be able to get rid of "Table" and just use:

Between [tblPayPeriod].[StartDate] And [tblPayPeriod].[EndDate]

If you can't add the table, you could probably use 2 DLookup()s or 2
subqueries in the criteria.

Between Dlookup("[StartDate]","[tblPayPeriod]") And Dlookup("[EndDate]",
"[tblPayPeriod]")

This assumes there is only one record in tblPayPeriod.


--
Duane Hookom
Microsoft Access MVP


"Larry" wrote:

> I have a simple time tracking database that I am creating. I have a table
> tblPayPeriod that just has two columns in it - StartDate and EndDate.
>
> I want to create criteria in the query that will only pull data from between
> the two dates, so I have tried to add this to the criteria:
>
> Between [Tables]![tblPayPeriod].[StartDate] And
> [Tables]![tblPayPeriod].[EndDate]
>
> But it is not working, HELP!

 
Reply With Quote
 
Jeff Boyce
Guest
Posts: n/a
 
      10th Nov 2008
Larry

"... not working ..." could mean anything. Is the query returning some data
or none? Wrong data or not all of the right data...? Is the PC shutting
down or blowing up?<g>

Also, "how" might depend on which version of Access you are using...

What happens if you remove the paramater prompts and use actual, "hardcoded"
dates in your "Between..." expression?

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Larry" <(E-Mail Removed)> wrote in message
news:7552B796-6C0C-43F9-B8B4-(E-Mail Removed)...
>I have a simple time tracking database that I am creating. I have a table
> tblPayPeriod that just has two columns in it - StartDate and EndDate.
>
> I want to create criteria in the query that will only pull data from
> between
> the two dates, so I have tried to add this to the criteria:
>
> Between [Tables]![tblPayPeriod].[StartDate] And
> [Tables]![tblPayPeriod].[EndDate]
>
> But it is not working, HELP!



 
Reply With Quote
 
floronDBA
Guest
Posts: n/a
 
      10th Nov 2008
On 10 nov, 16:52, Larry <La...@discussions.microsoft.com> wrote:
> I have a simple time tracking database that I am creating. I have a table
> tblPayPeriod that just has two columns in it - StartDate and EndDate.
>
> I want to create criteria in the query that will only pull data from between
> the two dates, so I have tried to add this to the criteria:
>
> Between [Tables]![tblPayPeriod].[StartDate] And
> [Tables]![tblPayPeriod].[EndDate]
>
> But it is not working, HELP!


The criteria look Ok, but Access will not know by itself what to apply
them to.

SOMETHING Between [Tables]![tblPayPeriod].[StartDate] And
[Tables]![tblPayPeriod].[EndDate]

Hope this helps
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      10th Nov 2008
On Mon, 10 Nov 2008 07:52:05 -0800, Larry <(E-Mail Removed)>
wrote:

>I have a simple time tracking database that I am creating. I have a table
>tblPayPeriod that just has two columns in it - StartDate and EndDate.
>
>I want to create criteria in the query that will only pull data from between
>the two dates, so I have tried to add this to the criteria:
>
>Between [Tables]![tblPayPeriod].[StartDate] And
>[Tables]![tblPayPeriod].[EndDate]
>
>But it is not working, HELP!


If you want to find all records for a particular date, use

>= [Enter date:]


as a criterion on StartDate, and

<= [Enter date:]

as a criterion on EndDate.

--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm trying to run a Query and specify if only dates are in table. =?Utf-8?B?Q2FuZHk=?= Microsoft Access Getting Started 1 6th Apr 2007 10:43 PM
how to query table by last 20 dates for each contact ID =?Utf-8?B?c2NyYXBweWR1ZQ==?= Microsoft Access Queries 3 2nd Jan 2006 05:37 AM
How do I query a table by dates? =?Utf-8?B?RERyb3dl?= Microsoft Access Queries 1 11th Aug 2005 08:33 PM
Between date for a Query from two dates in a Table =?Utf-8?B?S0Fub2U=?= Microsoft Access Queries 1 3rd Nov 2004 02:54 AM
Need table of all dates between two other dates as input to another query Benjamin White Microsoft Access 1 2nd Feb 2004 11:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:54 AM.