Solved

Query to get the soonest date out of a few records

Posted on 2016-09-28
2
52 Views
Last Modified: 2016-09-28
Hi there, I have a query that I want to modify so I can get the soonest date from a few different records

Set TicketDiscount=oConn.Execute("SELECT * FROM ticket_discount WHERE ticket_ID="&Request.QueryString("ticket"))

Open in new window


The records have dates of expiry, eg
ticket 1 exp=2/12/16
ticket 2 exp=8/5/1=7

What I want to do is grab the ticket that the expiry is soonest, how would I modify my query to do that?

Cheers all
0
Comment
Question by:Graeme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 41819316
hi,
do you mean this?

Set TicketDiscount=oConn.Execute("SELECT top 1 * FROM ticket_discount  order by Expiry_Date desc")

Open in new window

0
 

Author Closing Comment

by:Graeme
ID: 41819331
With a bit of playing here it is! :)

Set TicketDiscount=oConn.Execute("SELECT TOP 1 * FROM ticket_discount WHERE ticket_ID="&Request.QueryString("ticket")&" ORDER BY ticket_exp")
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question