Accounts Receivables aging

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


Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Query could be:
SELECT Sum(LineTotal) AS SumOfLineTotal
FROM YourTable
WHERE (((Date()-[MMDate])>30 And (Date()-[MMDate])<=60));

Open in new window

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAuthor Commented:
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)
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.