Records between specified dates

J

Joe

Hi folks,

The SQL statement beloe was supposed to select dates between July1, 2008 and
Sept 30, 2008 but it is returning all dates even from 2007. What do I need to
fix in the statement to get the dates I specified?


SELECT [Cost Containment Main Table (fixed)].AuditNumber, [Cost Containment
Main Table (fixed)].[Par Facility Provider], [Cost Containment Main Table
(fixed)].[Imaging Number], [Cost Containment Main Table (fixed)].LastName,
[Cost Containment Main Table (fixed)].FirstName, [Cost Containment Main Table
(fixed)].DateOfService, [Cost Containment Main Table (fixed)].AmountBilled
FROM [Cost Containment Main Table (fixed)]
WHERE ((([Cost Containment Main Table (fixed)].[Par Facility Provider]) Like
"Fairview*") AND (([Cost Containment Main Table (fixed)].DateOfService)
Between "7/1/2008" And "09/30/2008"));

Thanks.

Joe
 
D

Dale Fye

In Access, you have to use the # as date delimeters. Otherwise, it treats
the date values as text, and comparing a date to a text value does not work
well. Try:

Between #7/1/2008# And #09/30/2008#));

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
D

dgunning

Try delimiting your dates with # instead of ", ie:
Between #7/1/2008# And #09/30/2008#
 
J

Joe

Thank you Dale,

Simple but great solution.

Dale Fye said:
In Access, you have to use the # as date delimeters. Otherwise, it treats
the date values as text, and comparing a date to a text value does not work
well. Try:

Between #7/1/2008# And #09/30/2008#));

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Joe said:
Hi folks,

The SQL statement beloe was supposed to select dates between July1, 2008 and
Sept 30, 2008 but it is returning all dates even from 2007. What do I need to
fix in the statement to get the dates I specified?


SELECT [Cost Containment Main Table (fixed)].AuditNumber, [Cost Containment
Main Table (fixed)].[Par Facility Provider], [Cost Containment Main Table
(fixed)].[Imaging Number], [Cost Containment Main Table (fixed)].LastName,
[Cost Containment Main Table (fixed)].FirstName, [Cost Containment Main Table
(fixed)].DateOfService, [Cost Containment Main Table (fixed)].AmountBilled
FROM [Cost Containment Main Table (fixed)]
WHERE ((([Cost Containment Main Table (fixed)].[Par Facility Provider]) Like
"Fairview*") AND (([Cost Containment Main Table (fixed)].DateOfService)
Between "7/1/2008" And "09/30/2008"));

Thanks.

Joe
 
J

Joe

Thanks, "dgunning". Works.

Joe

dgunning said:
Try delimiting your dates with # instead of ", ie:
Between #7/1/2008# And #09/30/2008#

Joe said:
Hi folks,

The SQL statement beloe was supposed to select dates between July1, 2008 and
Sept 30, 2008 but it is returning all dates even from 2007. What do I need to
fix in the statement to get the dates I specified?


SELECT [Cost Containment Main Table (fixed)].AuditNumber, [Cost Containment
Main Table (fixed)].[Par Facility Provider], [Cost Containment Main Table
(fixed)].[Imaging Number], [Cost Containment Main Table (fixed)].LastName,
[Cost Containment Main Table (fixed)].FirstName, [Cost Containment Main Table
(fixed)].DateOfService, [Cost Containment Main Table (fixed)].AmountBilled
FROM [Cost Containment Main Table (fixed)]
WHERE ((([Cost Containment Main Table (fixed)].[Par Facility Provider]) Like
"Fairview*") AND (([Cost Containment Main Table (fixed)].DateOfService)
Between "7/1/2008" And "09/30/2008"));

Thanks.

Joe
 

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