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!

Result of Expression not sorting as Date

Status
Not open for further replies.

dar149

MIS
Mar 5, 2002
117
US
I have a query that finds the minimum date value from three date fields. When I sort the result it sorts as text rather than by the actual date. I have used the following expression:
Minimum Date: Minimum([GLExp],[UmbExp],[WCExp])

I tried formatting the field as a date, but if I sort or use Minimum Date in another query, it sees that field as text.

Any suggestions?
 
Why not posting the code of your Minimum function ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I created the expression in a query field.

Minimum Date: Minimum([GLExp],[UmbExp],[WCExp])
is one of the fields.
 
This is the code of the query:
SELECT [Contractor Table].Contractor, [Contractor Table].Administrator, Minimum([GLExp],[UmbExp],[WCExp]) AS [Minimum Date]
FROM [Contractor Table]
WHERE (((Minimum([GLExp],[UmbExp],[WCExp]))<>0) AND (([Contractor Table].Active)=Yes))
ORDER BY Minimum([GLExp],[UmbExp],[WCExp]);
 
Minimum, AFAIK, is not a standard JetSQL function, therefore you must have your own version.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OK, I rephrase my question:
where is your Minimum function coming from ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have no idea, I just typed it in and it gave me the lowest date from whichever field had the lowest date for each record.

Is there a better way to do this? I have three fields in each record that contain dates. I want the least recent date of the three fields to display for each record.
 
OK, as nobody knows nothing, you may try to replace this:
ORDER BY Minimum([GLExp],[UmbExp],[WCExp]);
with this:
ORDER BY CDate(Minimum([GLExp],[UmbExp],[WCExp]));

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top