Solved

Date in a Query

Posted on 2012-03-16
4
213 Views
Last Modified: 2012-03-16
Dear Experts,

I need to be able to create a field in a query which returns the first and last dates in a range ([DateAndTime]).  So something like "'First date' to 'Last date'"

This needs to be added into a query which then forms the dataset for a count query (the count is based on [DateAndTime]). I have tried playing around with the Expression Builder, but I’m not getting very far
The query I have is below ... Can anybody help?

SELECT FFUsers_Contact_Information.DateAndTime, FFUsers_ConsultantDefs.Description, FFUsers_ConsultantDefs.entry AS FFID
FROM FFUsers_UsersPreferences INNER JOIN (FFUsers_Contact_Information INNER JOIN FFUsers_ConsultantDefs ON FFUsers_Contact_Information.createby = FFUsers_ConsultantDefs.entry) ON FFUsers_UsersPreferences.user_log_in = FFUsers_ConsultantDefs.entry
GROUP BY FFUsers_Contact_Information.DateAndTime, FFUsers_ConsultantDefs.Description, FFUsers_ConsultantDefs.entry, FFUsers_UsersPreferences.is_current
HAVING (((FFUsers_UsersPreferences.is_current)=1)); 

Open in new window


Many thanks
0
Comment
Question by:correlate
  • 2
4 Comments
 
LVL 39

Expert Comment

by:als315
ID: 37728939
Add this field (DateAndTime) twice and select min and max in group functions
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 37728950
I'm not sure I understand what you are asking for.

Are you saying you want to know the values of the oldest and newest datetimes in the field DateAndTime?  

If so then it seems that you need a separate query..

Select min(Dateandtime) as FirstDate, max(dateandtime) as LastDate
from FFUsers_Contact_Information
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37728954
als315
... the query is grouping by DateAndTime so the max and min values will just be the same as the grouping value.
0
 

Author Closing Comment

by:correlate
ID: 37728997
Brilliant - thank you for that, does the trick perfectly
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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

759 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

19 Experts available now in Live!

Get 1:1 Help Now