I have a list of records that have a date/time field/column; I want a query to get just the distinct days (removing the time, like 1/1/14, 1/2/14, etc) & sorted correctly. Its going into a form's combo box row source so a user can filter/narrow-down the info on the screen per day
Here is my original query:
SELECT TOP 1 "*** ALL ***" AS ord_tdate FROM qryOrderEntriesNotBilled
UNION SELECT DISTINCT FORMAT(ord_tdate, "mm/dd/yy") FROM qryOrderEntriesNotBilled
ORDER BY 1;
Here is a simplified view for the sake of the question at hand:
SELECT DISTINCT FORMAT(ord_tdate, "mm/dd/yy") FROM qryOrderEntriesNotBilled
ORDER BY 1;
Both of the above work, but the order is wrong, its obviously sorting by number (1st one) rather than overall value as seen here:
Things I have tried unsuccessfully:
DATEVALUE(ord_tdate)
solved the simplified view, but with original query (union) it doesn't work correctly as seen belowCDate(Datevalue(ord_tdate))
&CDate(FORMAT(ord_tdate, "mm/dd/yy"))
had same results as above