Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding row with highest priority and earliest datetime

Status
Not open for further replies.

abds

Programmer
Dec 13, 2000
46
US
I have a record with a datetime field and a numeric priority field. I want to find the record with the highest priority and within priority, the earliest datetime.

In languages where date and times are numeric fields I can do indexfield=STR(priority,3,0)+STR((99999999-date),8,0)+STR((999999-time),6,0) to get what I want.

In VFP I have to use an even kludgier indexfield=STR(priority,3,0)+STR({^9999/12/31,11:59:59pm}-datetime),?,0).

1. How big should the second STR field be?
2. Can anyone think of an easier way around this?
 
SELECT * FROM myFile WHERE priorityCondition .AND. ;
MAX(DATE_TIME) .....
... using MAX is the key
ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
The correct suggestion is not what I already posted. This shall be ....

SELECT * FROM myFile WHERE condition ORDER BY priority, datetime ASC or DESC
GO BOTTOM or locate suitably ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Just an FYI:
Max(date)
Gives you the Most recent date.

Min(date) will give the earliest.

Sorry, had to add my 2 cents :eek:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top