Solved

access query counting entries by date

Posted on 2014-04-30
4
391 Views
Last Modified: 2014-05-01
Hi

I have a table which stores the datetime that a survey was completed, along with the surveyid... simple stuff...

my table is storing the date and time in the datetime field.

now I want to create a query that gives output like this:

01/01/2014 - 10
02/01/2014 - 21
03/01/2014 - 39
....


and so on.



SELECT pd_entries.time_stamp, Count(pd_entries.time_stamp) AS num, pd_entries.sessionid
FROM pd_entries
GROUP BY pd_entries.time_stamp, pd_entries.sessionid
HAVING (((pd_entries.sessionid)=5));

Open in new window



I am getting a count of 1 next to each date entry, because the time is different on each entry... doh..


time_stamp                      num      sessionid
29/04/2014 07:00:00      1      5
29/04/2014 07:44:17      1      5
29/04/2014 07:46:16      1      5
29/04/2014 07:56:25      1      5
29/04/2014 11:04:04      1      5
29/04/2014 11:05:03      1      5

is there any way for me to change the query to look just at the date?
0
Comment
Question by:cycledude
  • 2
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40031958
try

SELECT pd_entries.time_stamp, Count(datevalue(pd_entries.time_stamp)) AS num, pd_entries.sessionid
FROM pd_entries
GROUP BY datevalue(pd_entries.time_stamp), pd_entries.sessionid
HAVING (((pd_entries.sessionid)=5));
0
 

Author Comment

by:cycledude
ID: 40033920
Thanks, had a go, got the following message

"You tried to execute a query that does not include the specified 'time_stamp' as part of an aggregate function"
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40034309
sorry

SELECT datevalue(pd_entries.time_stamp), Count(datevalue(pd_entries.time_stamp)) AS num, pd_entries.sessionid
FROM pd_entries
GROUP BY datevalue(pd_entries.time_stamp), pd_entries.sessionid
HAVING (((pd_entries.sessionid)=5));
0
 

Author Closing Comment

by:cycledude
ID: 40034480
thanks ;o)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now