Link to home
Start Free TrialLog in
Avatar of surah79
surah79

asked on

Access Query

Hi Guys

I am trying to write a query which can provide me Monthly Total depends on the user input date and year to date total also in the same query.

My table has the fields : Application Id, Status, Date.

My query should give an out put

Total Record In Oct-13  = 10
YTD Record  Till Oct-13 =  50 (will Add all from Jan-13 -Oct-13)
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Something like the following should work.  BTW, you should not use [Date] as a field name in Access because it is a reserved name and must have brackets around it to represent the field (it conflicts with the Date() function).

SELECT Sum(iif(Format([Date]), "mmyy") = [YourDate], 1, 0) as MonthCount,
             Sum(iif(Format([Date]), "yy") = Right([YourDate], 2), 1, 0) as YearCount
FROM YourTable
Avatar of surah79
surah79

ASKER

Hi Fyed,

Its giving me an error function has wrong number of arguments.
SELECT Sum(iif(Format([ Decision Date]), "mmyy") = [YourDate], 1, 0) as MonthCount,
             Sum(iif(Format([Decision Date]), "yy") = Right([YourDate], 2), 1, 0) as YearCount
FROM Application
where status = 3;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial