A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date/Time criteria problem



 
 
Thread Tools Display Modes
  #1  
Old April 28th, 2010, 04:55 PM posted to microsoft.public.access.queries
Keith
external usenet poster
 
Posts: 531
Default Date/Time criteria problem

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

  #2  
Old April 28th, 2010, 05:45 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Date/Time criteria problem

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?


WHERE DateValue([ENTRY DATE])=#4/27/2010#

--
Marsh
MVP [MS Access]
  #3  
Old April 28th, 2010, 06:19 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Date/Time criteria problem

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

  #4  
Old April 28th, 2010, 06:26 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Date/Time criteria problem

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

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.