Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

do while loop to compare between dates

Status
Not open for further replies.
Aug 21, 2001
1
US
We have a table with data consisting of multiple dates with different data for each date (e.g. cusip). We would like to be able to select the date that is equal to or closest to (without being greater than) our input date. Should we use a "do while" loop? Or is there an SQL statement that would work? Please help!
 
Hi!

Check out the Max function in SQL. I think this works with dates also, though I have never tried it personally. If you combine the Max function in a query that limits the daes to being equal to or less than your target date, you should get back the date you are looking for.

hth
Jeff Bridgham

P.S. Again, this something I haven't tried so it will probably need some tweaking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top