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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date problem

Status
Not open for further replies.

Ragol1

Programmer
Oct 25, 2001
315
US
Check this out, I use this to display the last 6 updates, but 9/9/2002 is showing up before 9/10/2002 or 9/12/2002 because of the 9 being higher than the 1 of the 10 or 12, any Ideas on how to get round this.

Thanks

Nick



<%

dim cnn2,rst2

set cnn2 = Server.CreateObject(&quot;ADODB.Connection&quot;)

cnn2.Open &quot;driver={Microsoft Access Driver (*.mdb)};;DBQ=E:/writedatabase/Members.mdb;&quot;

SQL = &quot;SELECT Top 6 * from Members Order by update_date DESC&quot;

Set rs2 = cnn2.execute(SQL)

%> <TABLE BORDER=&quot;2&quot; BORDERCOLOR=&quot;#000000&quot; BORDERCOLORLIGHT=&quot;#CCCCCC&quot; BORDERCOLORDARK=&quot;#000000&quot; BGCOLOR=&quot;#0033CC&quot;>

<%

While rs2.EOF = false

%> <TR> <TD><FONT SIZE=&quot;3&quot;><%=rs2.fields(&quot;UserID&quot;)%></FONT></TD><TD><FONT SIZE=&quot;3&quot;><%=rs2.fields(&quot;update_date&quot;)%></FONT></TD></TR>

<%

rs2.MoveNext

WEND

%> </TABLE><%

rs2.Close()

set rs2 = nothing

cnn2.Close()

set cnn2 = nothing

%>
 
You must be saving your dates in a text or c\varchar field. When the system attempts to display these fields in order it evaluates the characters order as characters rather than dates. If you switch to a date field it should order just fine for you.
-Tarwn The three most dangerous things in the world are a programmer with a soldering iron, a hardware type with a program patch, and a user with an idea
-computer saying (Wiz Biz - Rick Cook)
 
or you could use this for your SQL:

SQL = &quot;SELECT Top 6 * from Members Order by convert(datetime,update_date) DESC&quot;

mwa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top