Print Page | Close Window

SQL String - ORDER BY

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3695
Printed Date: 29 March 2026 at 11:56pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: SQL String - ORDER BY
Posted By: silvaduro
Subject: SQL String - ORDER BY
Date Posted: 20 June 2003 at 9:10am

Hey,

My current SQL string is

strSQL = "SELECT news.* FROM news WHERE useridadmin = " & session("admin") & " ORDER BY postdate,posttime ASC"

Basically, what I want it to do is sort the news by it's date, and then within that by it's time.

So, say I had three entries...

1 - Date = 2/3/03 - Time = 12.31pm
2 - Date = 2/3/03 - Time = 1.56pm
3 - Date = 2/3/03 - TIme = 2.14pm

I would want to show them as

3
2
1

I hope you understand what I mean... I really need this.




Replies:
Posted By: Bluefrog
Date Posted: 20 June 2003 at 10:39am

Originally posted by silvaduro silvaduro wrote:

strSQL = "SELECT news.* FROM news WHERE useridadmin = " & session("admin") & " ORDER BY postdate,posttime ASC"

strSQL = "SELECT news.* FROM news WHERE useridadmin = " & session("admin") & " ORDER BY postdate DESC"

You should just keep the date as a date, which includes the time.

OR

strSQL = "SELECT news.* FROM news WHERE useridadmin = " & session("admin") & " ORDER BY postdate,posttime DESC"

 



Posted By: ljamal
Date Posted: 20 June 2003 at 2:53pm
My assumption is that you are looking to order everything from most recent to least recent so it should read:
strSQL = "SELECT news.* FROM news WHERE useridadmin = " & session("admin") & " ORDER BY postdate DESC,posttime DESC"

My suggestion is to store the date and time in a datetime field and then just sort by that field.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net