Date criteria

D

Domac

Hi I have two textboxes : FromDate and ToDate

Problem is when I enter same date in both of them i dont retrieve records
for that day.

FromDate = 6/14/2006
ToDate = 6/14/2006

generate query below:

SELECT Proizvodi.*
FROM Proizvodi
WHERE (((Proizvodi.Uneseno)>=#6/14/2006#)) AND
(((Proizvodi.Uneseno)<=#6/14/2006#));


I use this model to retreive records for period of time or (if dates are the
same) for exact date.


Why query above dont return records with date 6/14/2006???

Thanks a lot!
 
A

Allen Browne

Your date time field might contain time as well as date, in which case a
search for the exact date will return no records.

Try asking for everything from the particular date and less than the next
day:
SELECT Proizvodi.*
FROM Proizvodi
WHERE (((Proizvodi.Uneseno)>=#6/14/2006#)) AND
(((Proizvodi.Uneseno) < #6/15/2006#));

Or, to use your text boxes:
SELECT Proizvodi.*
FROM Proizvodi
WHERE Proizvodi.Uneseno >= [Forms].[Form1].[FromDate]
AND Proizvodi.Uneseno < ([Forms].[Form1].[ToDate] + 1);
 
D

Domac

You are right!!!
You MVPs really now stuff about Access!

Value in field is return value of Now function

I will convert field to pure date!
Thanks a lot!





Allen Browne said:
Your date time field might contain time as well as date, in which case a
search for the exact date will return no records.

Try asking for everything from the particular date and less than the next
day:
SELECT Proizvodi.*
FROM Proizvodi
WHERE (((Proizvodi.Uneseno)>=#6/14/2006#)) AND
(((Proizvodi.Uneseno) < #6/15/2006#));

Or, to use your text boxes:
SELECT Proizvodi.*
FROM Proizvodi
WHERE Proizvodi.Uneseno >= [Forms].[Form1].[FromDate]
AND Proizvodi.Uneseno < ([Forms].[Form1].[ToDate] + 1);

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Domac said:
Hi I have two textboxes : FromDate and ToDate

Problem is when I enter same date in both of them i dont retrieve records
for that day.

FromDate = 6/14/2006
ToDate = 6/14/2006

generate query below:

SELECT Proizvodi.*
FROM Proizvodi
WHERE (((Proizvodi.Uneseno)>=#6/14/2006#)) AND
(((Proizvodi.Uneseno)<=#6/14/2006#));


I use this model to retreive records for period of time or (if dates are
the same) for exact date.


Why query above dont return records with date 6/14/2006???

Thanks a lot!
 

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