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!

Dates not displaying correctly

Status
Not open for further replies.

chridd

MIS
Feb 7, 2005
12
US
I have a simple .asp page that displays dates in a dropdown box from a access database. There is one slight problem.. The dates are not in ascending order. It is in ascending order in access, but I can't seem to figure out what the problem is.
ie.
1/1/05
1/10/05
2/2/05
2/23/05
2/4/05
Any Suggestions?
 
Unfortunately that didnt help.. I still had the same problem.. Here is my code listed below:

<% Dim db, rsdept, sql
Set db = Server.CreateObject("ADODB.Connection")
db.Open "forms"
Set rsdept = Server.CreateObject("ADODB.Recordset")

sql = "SELECT DISTINCT stampdate FROM request"
sql = sql & " ORDER BY stampdate ASC"
'response.write sql
rsdept.open sql, db

Do until rsdept.eof

Response.write "<option value='" & rsdept("stampdate") & "'>" & rsdept("stampdate") & "</option>"
rsdept.movenext
Loop
Response.write "<hr width='80%' align='default' >"
rsdept.close
db.close
set rsdept = nothing
set db = nothing
%>
 
Did you mean...the below did not work??

sql = "SELECT DISTINCT stampdate FROM request"
sql = sql & " ORDER BY CONVERT(datetime,stampdate) ASC"

-SecondToNone
 
I figured out what the problem was. The stampdate was set as text instead of date/time in the access database.. I changed that and it displayed in the correct order.. Thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top