Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fewer steps to get to a certain record in a table?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00533040
Message ID:
00534244
Views:
13
>I have a table full of records with a date field in each record. The date field is D 8. For example I see 02/07/1999 when I browse the table. Of course there are other fields in the record, but the date field is the one I need to use to find the last record for a given year.
>
>My table has the following records with dates in them (the actual table has about 4000 records in it, but this is an example to illustrate what I am trying to accomplish -
>MyTable Date Field (D 8)
>03/06/1995
>03/07/1995
>01/04/1996
>07/04/1996
>09/22/1996
>02/22/1997
>08/15/1997
>11/27/1997
>12/22/1997
>04/07/1998
>05/19/1998
>and so on ...
>
>Can I locate the last record for 1997 in fewer steps? Right now, I have a SCAN ... ENDSCAN with a DO WHILE ... ENDDO running inside of that to locate the last record in a given year. It seems like there should be a way to go to the last record for a given year in a single command? I think I am going about this the long way.
>
>Help please and thank you.
Maybe ..
USE MyTable
INDEX ON DTOS(Date_Field) tag Date_Field
** Then when you need the last record for 1997
SELECT MyTable
SET ORDER TO Date_Field DESCENDING
SET EXACT OFF
SEEK "1997" && Your there!
SET EXACT ON
SET ORDER TO Date_Field
Imagination is more important than knowledge
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform