Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

GroupBy query with todays  date

Posted on 2014-07-21
9
Medium Priority
?
176 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 31

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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 …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

963 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