Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL String - ORDER BY
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL String - ORDER BY

 Post Reply Post Reply
Author
silvaduro View Drop Down
Newbie
Newbie
Avatar

Joined: 10 November 2002
Status: Offline
Points: 39
Post Options Post Options   Thanks (0) Thanks(0)   Quote silvaduro Quote  Post ReplyReply Direct Link To This Post Topic: SQL String - ORDER BY
    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.

Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post 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"

 

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.