query

S

sandrao

I Am having trouble with a Query. I want to use an "orderdate" in a combobox
to select dates for reports.
Here is what the query looks like: "SELECT DISTINCT
tblNewTransfer.[OrderDate] FROM tblNewTransfer ORDER BY
tblNewTransfer.OrderDate;". The problem is that it is not selecting distinct
dates it select all the dates which lists numerous duplicates. How can I
insure that the cbo will select only each different date with no duplicates?
 
J

John W. Vinson

I Am having trouble with a Query. I want to use an "orderdate" in a combobox
to select dates for reports.
Here is what the query looks like: "SELECT DISTINCT
tblNewTransfer.[OrderDate] FROM tblNewTransfer ORDER BY
tblNewTransfer.OrderDate;". The problem is that it is not selecting distinct
dates it select all the dates which lists numerous duplicates. How can I
insure that the cbo will select only each different date with no duplicates?

As Jason says, the problem is that your OrderDate field probably has values
like #11/17/2007 11:24:31am# and #11/17/2007 02:16:28pm# - which ARE distinct
values, though they will look the same if you format the field to show the
date portion only.

Try

SELECT DISTINCT DateValue(tblNewTransfer.[OrderDate]) FROM tblNewTransfer
ORDER BY DateValue(tblNewTransfer.OrderDate);

to truncate it to just the date portion.

John W. Vinson [MVP]
 
K

KARL DEWEY

Try this ---
SELECT DISTINCT DateValue(tblNewTransfer.[OrderDate]) FROM tblNewTransfer
ORDER BY DateValue(tblNewTransfer.OrderDate);

--
KARL DEWEY
Build a little - Test a little


Jason Lepack said:
They are distinct. They include times as well as dates though.

I Am having trouble with a Query. I want to use an "orderdate" in a combobox
to select dates for reports.
Here is what the query looks like: "SELECT DISTINCT
tblNewTransfer.[OrderDate] FROM tblNewTransfer ORDER BY
tblNewTransfer.OrderDate;". The problem is that it is not selecting distinct
dates it select all the dates which lists numerous duplicates. How can I
insure that the cbo will select only each different date with no duplicates?
 
Top