Spudhead
02-16-2010, 10:58 AM
I've got a database table that logs payments made to organisations. When a payment is made, two dates are logged: the actual date of the payment and, (because payments are usually made about a month in arrears), the 'To' cutoff date: that is, the payment covers a period from the last payment's 'To' date, up until this date. I hope that makes sense.
In addition, payments are categorised. Thus, the 'last payment' means the last payment of that category.
I need to list these payments. For each row of payment detail, I need to display a 'From' and 'To' date.
If I get a list in ascending date order (ie: oldest first), then the matter is simple. As I proceed through the recordset, I note what the 'To' date is for that payment (and which category it is), and use that as the 'From' date next time a payment in that category crops up.
The client now wants it in descending date order :(
I am stumped.
I can see a number of possibilities; they all involve horrendous multiple-looping though recordsets or building fascinatingly intricate arrays of next-date-for-the-last-date-payment-date, etcetera.
Can anyone whose brain isn't quite so fried suggest a simple, elegant and efficient way of looking ahead a few rows to find the next - that is, the previous - payment 'To' date?
:o:(
In addition, payments are categorised. Thus, the 'last payment' means the last payment of that category.
I need to list these payments. For each row of payment detail, I need to display a 'From' and 'To' date.
If I get a list in ascending date order (ie: oldest first), then the matter is simple. As I proceed through the recordset, I note what the 'To' date is for that payment (and which category it is), and use that as the 'From' date next time a payment in that category crops up.
The client now wants it in descending date order :(
I am stumped.
I can see a number of possibilities; they all involve horrendous multiple-looping though recordsets or building fascinatingly intricate arrays of next-date-for-the-last-date-payment-date, etcetera.
Can anyone whose brain isn't quite so fried suggest a simple, elegant and efficient way of looking ahead a few rows to find the next - that is, the previous - payment 'To' date?
:o:(