Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 29th, 2008, 01:52 AM
Registered User
 
Join Date: Dec 2006
Location: Islamabad, , Pakistan.
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
__________________
Saifi
Reply With Quote
  #2 (permalink)  
Old February 29th, 2008, 03:49 AM
Friend of Wrox
 
Join Date: Oct 2007
Location: , , .
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.
Reply With Quote
  #3 (permalink)  
Old February 29th, 2008, 03:51 AM
Friend of Wrox
 
Join Date: Oct 2007
Location: , , .
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.
Reply With Quote
  #4 (permalink)  
Old March 1st, 2008, 06:40 PM
Friend of Wrox
Points: 6,468, Level: 34
Points: 6,468, Level: 34 Points: 6,468, Level: 34 Points: 6,468, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,835
Thanks: 12
Thanked 16 Times in 16 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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08:19 AM
Help with Unbound Date field to link with SQL VBA JackalBW BOOK: Access 2003 VBA Programmer's Reference 0 December 9th, 2007 05: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



All times are GMT -4. The time now is 02:13 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.