Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for latest Date
Message
 
To
10/03/2005 14:59:33
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00994588
Message ID:
00994625
Views:
17
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>I'm trying to write a query to return records from a table that are closest to a certain date. I'm not sure what the syntax should look like in my SQL select statement. Any ideas would be greatly appreciated. Thanks!
>
>Tim

You need to be more explicit...
Something like:
*-- return 10 transaccions closest to Jan-15-2005
query_date = {^2005/15/01}
select top 10 trans_num, trans_date, (abs(trans_date-query_date)) as ndays ;
       from trans_table ;
       order by 3,1
or
*-- return transaccions within 3 days from Jan-15-2005
query_date = {^2005/15/01}
select trans_num, trans_date ;
       from trans_table ;
       where (abs(trans_date-query_date)) <= 3 ;
       order by 1

Just an opinion... Not a fact.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform