AGE() returns the age, in days, of a specified date compared to a specified cutoff date (or data constant).
Use AGE() when comparing two dates to determine overdue accounts or to perform aged analyses of balances.
AGE(C|D <,C|D>)
AGE() returns a numeric value denoting the age difference in days between two dates. When you omit the second parameter, Analyzer uses the current system date. But when you include the second parameter, Analyzer calculates age relative to fiscal year ends or other cutoff dates.
Regardless of the format in which a date field is stored, when using constants, the constant must be:
• | A character string or expression of the form YYYYMMDD |
• | A date constant of the form YYYYMMDD |
• | A valid Analyzer date expression |
Dates older than the cutoff date return a positive value. Dates more recent than the cutoff date return a negative value.
Acceptable dates are in the range January 1, 1900 to December 31, 9999.
Assuming a current system date of January 1, 2006:
AGE(‘20051220‘)=12
AGE(‘20060108‘)=-7
AGE(‘20041230‘,‘20050101‘)=12
To extract the name, amount and invoice date for all items whose INVOICE_DATE value is more than 180 days old (as at the fiscal year end of December 31, 2005), specify the condition:
AGE(INVOICE_DATE,‘20051231‘) > 180