Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fewer steps to get to a certain record in a table?
Message
De
20/07/2001 11:38:41
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00533040
Message ID:
00533196
Vues:
13
Hey Steve,
select max(datefield),* from mytable where year(datefield)=1997
This will return the row representing the highest date in 1997.

>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.
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform