Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looking for the oldest non-blank date
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Looking for the oldest non-blank date
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows 2000
Database:
Visual FoxPro
Divers
Thread ID:
01015389
Message ID:
01015389
Vues:
64
Hello Foxperts,

Did I do this the best way, or is there another/better way?

The application schedules preventive maintenance on equipment. Each item subject to PM is assigned an Area (essentially a supervisor), a Station (where it is located), and a Crew (which crew under a supervisor will do the PM). There are two kinds of maintenance, minor (like ckecking the oil) and major (like changing the oil). My challenge was to issue a block of work orders when anything in an Area-Station-Crew grouping was due, rather than letting them trickle out one or two at a time based solely on the due date.

One of the tricks was that for some items, either the nextminor or nextmajor date fields were blank based on the nature of the equipment.
I've come up with the following code:
SELECT AreaFK, StationFK, CrewFK, ;
	MIN(IIF(ISBLANK(nextminor),DATE()+4000,nextminor)) AS NextMinor, ;
	MIN(IIF(ISBLANK(nextmajor),DATE()+4000,nextmajor)) AS NextMajor, ;
	.F. AS doMinGroup, .F. AS doMajGroup ;
	FROM premaint  GROUP BY 1,2,3  ORDER BY 1,2,3 ;
	INTO TABLE maintdue
Now the app can go back to the premaint table and flag all records that are due for maintenance in the next week, and print the workorders.

I'm satisfied with the results I'm getting so far, and would like to thank everyone who takes time to review my code.
Randy Bosma
VFP - Because life is too short to code in something else...
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform