By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,395 Members | 2,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,395 IT Pros & Developers. It's quick & easy.

Need help with Month function

jenkinsloveschicken
P: 56
Could someone please take a look at my query and tell me what I am missing? The strange thing is that when I first built the query, it was working fine. Then it broke. I suspect the problem is the Call Date field. Without the Call Date parameter the query runs fine. However I need the Call Date field so that I can specify the Month function to pull the cumulative data for month-to-date based on the current month(Unless someone else has a better method of doing this). I double checked my data types for the Call Date field and it is the same as when I first built the query. The goal is to calculate averages from the fields listed below and group by the line of business. At any rate, here is the query:

Avg([Centerwide CSAT].[Spnt Sat]) AS Spnt_Top_2 : Returns an average rating for company brand satisfaction

Avg([Centerwide CSAT].[Specialist Sat]) AS Specialist_Top_2 : Returns an average rating for specialist satisfaction

Avg(IIf([Centerwide CSAT].[Issue Rslv]<>'NA',[Centerwide CSAT].[Issue Rslv])) AS Issue_Resolved_Average : Returns an average value for Issue Resolved rankings excluding values of N/A

[Center Headcount].Account : Returns the line of business


SELECT Avg([Centerwide CSAT].[Spnt Sat]) AS Spnt_Top_2, Avg([Centerwide CSAT].[Specialist Sat]) AS Specialist_Top_2, Avg(IIf([Centerwide CSAT].[Issue Rslv]<>'NA',[Centerwide CSAT].[Issue Rslv])) AS Issue_Resolved_Average, [Center Headcount].Account
FROM [Centerwide CSAT] INNER JOIN [Center Headcount] ON [Centerwide CSAT].[Specialist Name] = [Center Headcount].Name
GROUP BY [Center Headcount].Account, [Centerwide CSAT].[Call Date]
HAVING ((([Centerwide CSAT].[Call Date])=(Month(Now()))));


Thanks,
Gerald
Jan 4 '07 #1
Share this Question
Share on Google+
5 Replies


Expert 5K+
P: 8,434
That's a very clear and detailed problem description, which is always a nice thing to see. However, could you please provide further detail on how it "broke"?
Jan 5 '07 #2

ADezii
Expert 5K+
P: 8,638
Could someone please take a look at my query and tell me what I am missing? The strange thing is that when I first built the query, it was working fine. Then it broke. I suspect the problem is the Call Date field. Without the Call Date parameter the query runs fine. However I need the Call Date field so that I can specify the Month function to pull the cumulative data for month-to-date based on the current month(Unless someone else has a better method of doing this). I double checked my data types for the Call Date field and it is the same as when I first built the query. The goal is to calculate averages from the fields listed below and group by the line of business. At any rate, here is the query:

Avg([Centerwide CSAT].[Spnt Sat]) AS Spnt_Top_2 : Returns an average rating for company brand satisfaction

Avg([Centerwide CSAT].[Specialist Sat]) AS Specialist_Top_2 : Returns an average rating for specialist satisfaction

Avg(IIf([Centerwide CSAT].[Issue Rslv]<>'NA',[Centerwide CSAT].[Issue Rslv])) AS Issue_Resolved_Average : Returns an average value for Issue Resolved rankings excluding values of N/A

[Center Headcount].Account : Returns the line of business


SELECT Avg([Centerwide CSAT].[Spnt Sat]) AS Spnt_Top_2, Avg([Centerwide CSAT].[Specialist Sat]) AS Specialist_Top_2, Avg(IIf([Centerwide CSAT].[Issue Rslv]<>'NA',[Centerwide CSAT].[Issue Rslv])) AS Issue_Resolved_Average, [Center Headcount].Account
FROM [Centerwide CSAT] INNER JOIN [Center Headcount] ON [Centerwide CSAT].[Specialist Name] = [Center Headcount].Name
GROUP BY [Center Headcount].Account, [Centerwide CSAT].[Call Date]
HAVING ((([Centerwide CSAT].[Call Date])=(Month(Now()))));


Thanks,
Gerald
It seems to me as though in your HAVING clause, you are trying to equate a Date Field [Call Date], to an Integer value Month(Now()) returned from the Month() Function. Have you tried this in the HAVING clause instead?
Expand|Select|Wrap|Line Numbers
  1. HAVING (((Month([Centerwide CSAT].[Call Date]))=(Month(Now()))));
Jan 5 '07 #3

Expert 5K+
P: 8,434
It seems to me as though in your HAVING clause, you are trying to equate a Date Field ... to an Integer value Month(Now()) ...
Good catch! I missed that.

Still too many parentheses though, in my opinion. That's not a bug or anything, I just hate the way Access throws in great long unnecessary strings of the stupid things.
Jan 5 '07 #4

jenkinsloveschicken
P: 56
I am unsure of how it broke. I initially had problems with the Call Date parameter resulting in no records. So I played with the data type(original was Date/Time and I had changed it to Text) for the call date to see if it was a reference problem with the Month function. With the data type as Text, it results in inaccurate results, but Date/Time datatype is accurate in the report output. To be honest, I don't completely understand the all of the date functions in Access.

The query minus Call Date will run all of the appropriate averages for each line of business. However, the output is to a subform on one of the Main forms in the database and I would like it to always pull the averages based on month-to-date information in the underlying table. Is there an easier or more effective way to do this?

Also, I'm kinda lost with the original reply:
It seems to me as though in your HAVING clause, you are trying to equate a Date Field [Call Date], to an Integer value Month(Now()) returned from the Month() Function. Have you tried this in the HAVING clause instead?

What is meant by: Have you tried this in the HAVING clause instead? Do I need to manipulate the HAVING clause itself? Or change the datatype for the Call Date field to something else?

Thanks for the help, as it is much appreciated!

Regards,
Gerald
Jan 5 '07 #5

jenkinsloveschicken
P: 56
Sorry, I just went back and re-read the original reply and noticed the difference in the code. Thank you, I will try that and let you know if it works! Again, thanks for the help!
Jan 5 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.