Solved

GroupBy query with todays  date

Posted on 2014-07-21
9
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 31

Accepted Solution

by:
Helen Feddema earned 500 total points
ID: 40209028
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
ID: 40209058
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
ID: 40209224
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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 3

Author Comment

by:fordraiders
ID: 40209244
The result i'm looking for is a count

CountOfProcRun
  8
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 40209359
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
ID: 40209434
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
ID: 40209818
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
ID: 40209819
hnasr, I will check that query..Thanks
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 40210006
using date function, just ended up nesting 2 queries.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

630 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