Accounts Receivables aging

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc used Ask the Experts™
The above formula is an example of multiple IF statements in excel or multiple criteria where each criteria is joined using AND function. AND function does literally the same thing as the and does in language. So the above formula will be read like this in plain English:
If difference between today’s date and the date in cell C5 is less than or equal to 60 days AND the difference between today’s date and the date in cell C5 is greater than 30 days than fetch the value from cell D5 otherwise put 0.

$C5 represents the filed date
$D5 represents the invoice amount

Now in excel it works very I have tested it , I want to use it in MS Access as well , I have tried like below but it does not work:


The above code is supposed to age those amounts in above 30 days and below 60 days

How do I fix it

Sorry to disturb your holiday


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Query could be:
SELECT Sum(LineTotal) AS SumOfLineTotal
FROM YourTable
WHERE (((Date()-[MMDate])>30 And (Date()-[MMDate])<=60));

Open in new window

Still what about >60 days >90 days > 120 days
or simple terms

Why this code does not work in Ms Access



=IIF(AND (Datediff("d",[MMDate],Date()))<=60,(Datediff("d",[MMDate],Date())>30),[LineTotal],0)

Could it be the AND operator???????
Access syntax differs from Excel. In Access you can use
In your samples calculation is made twice, in my sample - only one time. If you have huge tables it may be important. In Access you can select only records, with matched criteria and sum all records.
Your syntax could be:
=IIF((Datediff("d",[MMDate],Date()))<=60 AND (Datediff("d",[MMDate],Date())>30),[LineTotal],0)
Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014
You can also create a query that shows the Invoice number and number of Days Old and then use that in a second query. To do that, add the Invoice column and then a second aliased column that calculates the DaysOld:

SELECT Invoice, DateDiff("d", YourDateField, Date) AS DaysOld

Save that, then create a second query that includes the first, and Join them on the common field

SELECT * FROM SomeTable INNER JOIN YourSecondQuery ON SomeTable.Invoice=YourSecondQuery.Invoice WHERE DaysOld <=60 AND DaysOld >30

If you want all of them in a single query, create 3 queries (or however many you need) and then combine all of those in a "master" query, using the UNION operator:

SELECT Col1, Col2, Col3, etc  FROM  CurrentQuery UNION SELECT Col1, Col2, Col3, etc  FROM 30DayQuery UNION SELECT Col1, Col2, Col3, etc  FROM 60DayQuery

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial