Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy Date Question

Status
Not open for further replies.

NateUNI

MIS
Jan 3, 2002
132
US
Im trying to do a easy query,

SELECT BugTracking.[Reported Date]
FROM BugTracking
WHERE (((BugTracking.[Reported Date]) Like #12/15/2003#));

which returns 0 records, however the Reported Date field in the database is a type date/time so if i do this query:

SELECT BugTracking.[Reported Date]
FROM BugTracking
WHERE (((BugTracking.[Reported Date]) Like #12/15/2003 2:55:25 PM#));

it returns a record. How do I change my first query so that i can only pass it a date and it will find all dates the match it? Thanks!!
 
SELECT DateValue([Reported Date]) as ReportedDate
FROM BugTracking
WHERE [Reported Date] = #12/15/2003#;

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
I tried this,

SELECT DateValue([Reported Date]) AS ReportedDate, BugTracking.[Tracking Number]
FROM BugTracking
WHERE (((BugTracking.[Reported Date]) = #12/15/2003#));

and it does not bring back any rows, any other ideas, Thanks!!
 
the problem seems to be that the stored datetime values include a time component, whereas when you compare to a literal like #12/15/2003# which has no time component therefore it defaults to 00:00 and does not match

so try this:

[tt]WHERE format(BugTracking.[Reported Date]
,"mm/dd/yyyy") = '12/15/2003'[/tt]

note that FORMAT() produces a character string, so it is compared to '12/15/2003' not #12/15/2003#

rudy
 
Sorry, the sql should have been:
SELECT [Reported Date] , [Tracking Number]
FROM BugTracking
WHERE DateValue([Reported Date]) = #12/15/2003#;

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top