Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 29th, 2008, 02:52 AM
Registered User
 
Join Date: Dec 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using ORDER BY in SQL on date field in ASP page

Dear All
I am using ASP for getting data from database and display now i want to sort my data while i am displaying it on webpage by date the existing query i am using is
strSQLAcc = "SELECT Accounts.* FROM Accounts WHERE Accounts.RegNo = " & rsSociety.Fields("RegNo").Value
any one can help me to rewrite this query according to my new requirement
thank you


Saifi
 
Old February 29th, 2008, 04:49 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

"SELECT Accounts.* FROM Accounts WHERE Accounts.datecol = '" & format(rsSociety.Fields("datecol").Value,"dd-MMM-yyyy") & "'"

confirm aruguments of format function, I am not sure about it.

urt

Help yourself by helping someone.
 
Old February 29th, 2008, 04:51 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

I think I made a mistake

"SELECT Accounts.* FROM Accounts WHERE Accounts.RegNo = " & rsSociety.Fields("RegNo").Value & " order by accounts.datecol"

urt

Help yourself by helping someone.
 
Old March 1st, 2008, 07:40 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Since you say:

;;;I am using ASP for getting data from database and display

I assume your query is working ok? Not sure why urtrivedi altered it..... Anyhow to order an existing working query you simply append:

" ...... ORDER BY [yourDateFieldName];"

NOTE - Its a good practice to place trailing semi colons at the end of any query. I assume 'yourDateFieldName' is a date data type? It needs to be to get what you want. Remember things are ordered ascending by default. To reverse this you need to place DESC at the end of the query

Wind is your friend
Matt
www.elitemarquees.com.au





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error - Loading date field from flat file to sql carumuga SQL Server 2005 0 August 12th, 2008 09:55 AM
Using ORDER BY in SQL query in ASP page saifi4u Classic ASP Databases 1 February 29th, 2008 09:19 AM
Help with Unbound Date field to link with SQL VBA JackalBW BOOK: Access 2003 VBA Programmer's Reference 0 December 9th, 2007 06:29 AM
Query a Sql Database Date Field feets Access VBA 3 October 18th, 2007 10:10 AM
ASP SQL fields in order ALoPresto Classic ASP Databases 2 July 25th, 2003 02:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.