Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Function on Date Field 2

Status
Not open for further replies.

diggerbob

Technical User
May 20, 2004
24
US
I have a report that I use that shows my natural gas usage per day. I also have to show how many days per month it was used. I have a count function set on the report but recently I have came across a problem. There will be days that we shut down and start back up on the same day, maybe even 3 times. I have to make separate entries for each start up using the same date. This causes my "days used" to come up as, i.e. 35 or 36 days for the month.
This is the way that I have my field formulated.
=Count([Limestone Gas Meter Reading Query]!Date)
Can anyone help on this!
Thanks, Bob
 
One way is to use nested queries (tested).
QryDistinctDate
Code:
SELECT d1.GiftDate
FROM donations AS d1
GROUP BY d1.GiftDate;
Then, add an outer query
Code:
SELECT Count(qryDistinctDate.GiftDate) AS CountOfGiftDate
FROM qryDistinctDate;

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
You can create a subquery in you report's record source that counts unique dates. For instance in the Northwind.mdb you can create a column of unique order dates with a column/field expression like:
Code:
 DistinctOrderDates: (SELECT Count(*) FROM (SELECT DISTINCT OrderDate FROM ORDERS) )
There are 830 records in the ORDERS table but the expression returns 480.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top