Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Latest Date Record
Message
From
21/05/2017 07:11:11
 
 
To
20/05/2017 08:41:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01651259
Message ID:
01651276
Views:
61
>I have a vfp 6.0 table that contain date senstive entries:
>
>Table name: SearchTrack.dbf
>search_name
>search_desc
>search_date
>
>The max searches a user can have is (4), so when the user tries to search a 5th time, i want to grab the record with the latest search date and simply replace the search name, desc fields as well as update the search_date field with the new system date.

I assume you mean you want to earliest, not the latest, but if you really mean latest, flip the sign here.
UPDATE SearchTrack ;
   SET Search_Name = m.NewName, ;
           Search_Desc = m.NewDesc, ;
           Search_Date= DATETIME() ;
   WHERE Search_Date = (SELECT MIN(search_date) FROM SearchTrack)
I've assumed that Search_Date is actually a DateTime, so that it can be used to actually uniquely choose the oldest. If it's just a date, you have to deal with the possibility of having two records with the same value. (Technically, that's true for datetime as well, but that seems unlikely in your use case.)

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform