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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RETURN A NEAREST VALUE FROM SQL

Status
Not open for further replies.

NW

Programmer
Feb 3, 2000
61
GB
Is there a function to return the nearest matching value from a SQL statement as shown below?

DBF fields
------------------
Date Time
01/02/1993 0945
04/02/1998 1048
04/02/1996 1050


If user input 1048
SQL should return 1048 (exact match)

If user input 1046
SQL should return 1045 (nearest match)

Any help on this greatly appreciated.
NW
[sig][/sig]
 
select top 1 date, time
from MyData
where time <= MyValue
order by time descending [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top