PC Review


Reply
Thread Tools Rate Thread

Date/Time criteria problem

 
 
Keith
Guest
Posts: n/a
 
      28th Apr 2010
I am trying to create a query that allows a user to select a specific date
for which to show results. Following is sample SQL with a fixed criteria:

SELECT qryShopJobsIO1.JOB_NO, qryShopJobsIO1.[TOTAL QUANTITY ORDERED],
qryShopJobsIO1.[ENTRY DATE], qryShopJobsIO1.SumOfTotalHours
FROM qryShopJobsIO1
WHERE (((qryShopJobsIO1.[ENTRY DATE])=#4/27/2010#));


This particular example returns no records. I know that I have records for
which the ENTRY DATE field is 4/27/2010. I believe that the problem is that
the default value of that field (in the table definition) is set to =Now()
(as opposed to Date()), which means that the date/time field probably
contains some time information. What can I do to "massage" the ENTRY DATE so
that I can use a single date criteria?

Thanks in advance,

Keith

 
Reply With Quote
 
 
 
 
Daryl S
Guest
Posts: n/a
 
      28th Apr 2010
Keith -

You can use just the date portion of the ENTRY DATE in the WHERE string by
using the DateValue function, like this:

SELECT qryShopJobsIO1.JOB_NO, qryShopJobsIO1.[TOTAL QUANTITY ORDERED],
qryShopJobsIO1.[ENTRY DATE], qryShopJobsIO1.SumOfTotalHours
FROM qryShopJobsIO1
WHERE (((DateValue(qryShopJobsIO1.[ENTRY DATE]))=#4/27/2010#));

--
Daryl S


"Keith" wrote:

> I am trying to create a query that allows a user to select a specific date
> for which to show results. Following is sample SQL with a fixed criteria:
>
> SELECT qryShopJobsIO1.JOB_NO, qryShopJobsIO1.[TOTAL QUANTITY ORDERED],
> qryShopJobsIO1.[ENTRY DATE], qryShopJobsIO1.SumOfTotalHours
> FROM qryShopJobsIO1
> WHERE (((qryShopJobsIO1.[ENTRY DATE])=#4/27/2010#));
>
>
> This particular example returns no records. I know that I have records for
> which the ENTRY DATE field is 4/27/2010. I believe that the problem is that
> the default value of that field (in the table definition) is set to =Now()
> (as opposed to Date()), which means that the date/time field probably
> contains some time information. What can I do to "massage" the ENTRY DATE so
> that I can use a single date criteria?
>
> Thanks in advance,
>
> Keith
>

 
Reply With Quote
 
Jerry Whittle
Guest
Posts: n/a
 
      28th Apr 2010
SELECT qryShopJobsIO1.JOB_NO,
qryShopJobsIO1.[TOTAL QUANTITY ORDERED],
qryShopJobsIO1.[ENTRY DATE],
qryShopJobsIO1.SumOfTotalHours
FROM qryShopJobsIO1
WHERE qryShopJobsIO1.[ENTRY DATE]
Between #4/27/2010# And #4/27/2010# + 0.9999 ;

If you want the users to be prompted for the date:

PARAMETERS [Enter the Date] DateTime;
SELECT qryShopJobsIO1.JOB_NO,
qryShopJobsIO1.[TOTAL QUANTITY ORDERED],
qryShopJobsIO1.[ENTRY DATE],
qryShopJobsIO1.SumOfTotalHours
FROM qryShopJobsIO1
WHERE qryShopJobsIO1.[ENTRY DATE]
Between [Enter the Date] and [Enter the Date] + 0.9999 ;

--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Keith" wrote:

> I am trying to create a query that allows a user to select a specific date
> for which to show results. Following is sample SQL with a fixed criteria:
>
> SELECT qryShopJobsIO1.JOB_NO, qryShopJobsIO1.[TOTAL QUANTITY ORDERED],
> qryShopJobsIO1.[ENTRY DATE], qryShopJobsIO1.SumOfTotalHours
> FROM qryShopJobsIO1
> WHERE (((qryShopJobsIO1.[ENTRY DATE])=#4/27/2010#));
>
>
> This particular example returns no records. I know that I have records for
> which the ENTRY DATE field is 4/27/2010. I believe that the problem is that
> the default value of that field (in the table definition) is set to =Now()
> (as opposed to Date()), which means that the date/time field probably
> contains some time information. What can I do to "massage" the ENTRY DATE so
> that I can use a single date criteria?
>
> Thanks in advance,
>
> Keith
>

 
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
Date/Time Criteria =?Utf-8?B?SG93YXJk?= Microsoft Access 3 24th Nov 2006 06:48 PM
Criteria on date/time field =?Utf-8?B?TWF0dCBEIEZyYW5jaXM=?= Microsoft Access Queries 5 13th Oct 2005 06:56 PM
Date/Time Fields criteria =?Utf-8?B?U2ltb24=?= Microsoft Access Queries 5 24th Sep 2005 01:27 PM
Like statement for date/time criteria one1george Microsoft Access Form Coding 5 21st Oct 2004 05:51 PM
Date and Time Criteria Jerrett Microsoft Access Queries 2 11th Oct 2003 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:45 AM.