Solved

GroupBy query with todays  date

Posted on 2014-07-21
9
165 Views
Last Modified: 2014-07-21
Access 2010:

SELECT Count(dbo_Desc_Search_Log.ProcRun) AS CountOfProcRun, dbo_Desc_Search_Log.QueryDate
FROM dbo_Desc_Search_Log
GROUP BY dbo_Search_Log.ProcRun, dbo_Desc_Search_Log.QueryDate
HAVING (((dbo_Desc_Search_Log.ProcRun)="1"));

I need to run this same query but only include records from todays date from the field.

 dbo_Desc_Search_Log.QueryDate

The format for this field is like this:
7/21/2014 8:35:35 AM

Just need with todays date(everyday)  


Thanks
fordraiders
0
Comment
Question by:fordraiders
  • 5
  • 3
9 Comments
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
Comment Utility
If QueryDate is a Date field, then adding a Where clause should do it:
WHERE QueryDate = Date()

If not, then you would need to convert it to a Date value using CDate().
0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
i have tried  =date()

CountOfProcRun      QueryDate
1      7/21/2014 8:57:15 AM
1      7/21/2014 8:56:59 AM
1      7/21/2014 8:56:34 AM
1      7/21/2014 8:56:25 AM
1      7/21/2014 8:56:24 AM
1      7/21/2014 8:56:21 AM
1      7/21/2014 8:56:21 AM
1      7/21/2014 8:56:18 AM

Just trying to get everything starting with todays date... without say explicitly 7/21/2014...the time does not matter.
0
 
LVL 31

Expert Comment

by:Helen_Feddema
Comment Utility
It looks as if you are getting the results you want -- all those records have today's date.  Is there still a problem?  If so, what is the problem?
0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
The result i'm looking for is a count

CountOfProcRun
  8
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 31

Expert Comment

by:Helen_Feddema
Comment Utility
Make a calculated field like this:  Format(QueryDate, "m/d/yyyy"), and do a count on that.  This will eliminate the times that are causing separate records.  You may have to tweak the query to make sure that other fields don't cause extra records.  It would help if you could post the database, or a cut-down version of it.
0
 
LVL 30

Expert Comment

by:hnasr
Comment Utility
Try:

SELECT Count(dbo_Desc_Search_Log.ProcRun) AS CountOfProcRun, 
              FORMAT(dbo_Desc_Search_Log.QueryDate,"mm/dd/yyyy")
 FROM dbo_Desc_Search_Log
 GROUP BY dbo_Search_Log.ProcRun, FORMAT(dbo_Desc_Search_Log.QueryDate,"mm/dd/yyyy")
 HAVING (((dbo_Desc_Search_Log.ProcRun)="1"));

Open in new window

0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
ok but i need it specifically for today's date..
in  this case 7/21/2014

tomorrow
7/21/2014
0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
hnasr, I will check that query..Thanks
0
 
LVL 3

Author Closing Comment

by:fordraiders
Comment Utility
using date function, just ended up nesting 2 queries.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

771 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

11 Experts available now in Live!

Get 1:1 Help Now