There's function called Get ( CurrentDate ) that you can use so you don't need a global field with a script that inserts the date each time. You can just refer to it.
This calculation will return the number of days a transaction is past due:
Get ( CurrentDate ) - Transaction Date
If you have a field in the table that identifies whether the item is paid or not by storing a 1 if paid and a 0 if not, you can enhance the calculation this way:
If ( not PaidField ; get ( CurrentDate ) - Transaction Date ; "" )
( ; "" added for clarity, if you leave that term out, you get the same results )
This must be an unstored calculation to reevaluate correctly with each new day, which can slow down searches and sorts on this field, but using a global field in place of get ( currentdate ) will also make the calculation unstored.
Brilliant - thanks. And it allows the setting up of unpaid categories as a secondary calculation!
A follow up suggestion. Say you have over 10,000 records and you want to find all unpaid transactions that are 60 days or older. Entering search criteria in the days past due calculation field forces filemaker to first index the field then perform the find and this can take a long time.
Instead, perform find that just uses the paidfield--which can be a stored, indexed field to find all unpaid transactions. Then enter find mode again, specify the > 60 criterion in the past due field and use Constrain Found Set to narrow the records down to just those that are unpaid, 60 days past due. You get to the final result, many times quicker!