I have a pretty basic query, but I’d like it to return the results in order from the earliest time to the latest. The column in question is a “short time.” This is what I have right now:
SELECT *
FROM tasksetup
ORDER BY whenend ASC
What’s the proper syntax to get this to work?
As an update:
When I run this query, it works just fine in that it completes. However, the completed query is not ordered the way I’d like. It returns the results in about the same order as they are in the table, rather than ordered by whenend.
Update 2: I guess it does work. I don’t know what was different yesterday, but now its ordering just fine. Oh computer science.
I don’t see why your query doesn’t work … unless whenend includes a date component which is not visible in your format. The Jet/ACE Date/Time data type always includes an integer component to represent the date; the fractional component represents the time of day.
See what you get with this:
Perhaps this session in the Immediate Window will help clarify Date/Time data type:
Update: I created a table named tasksetup with a Date/Time field named whenend with the field’s Format property set to Short Time. And I added 2 rows. Running your original query produces this result, which is apparently wrong:
However, the query I suggested runs without error, and reveals what is really going on:
You can use the TimeValue() function to ignore the date component of Date/Time values. Perhaps this query would give you the results you originally wanted.