How do I count dates in a month?

J

JOM

I have a table named tracking with the following fields date and tasks. I
would like to count how many days in a month that the tasks occured. e.g. if
on the 05/05/05 3 tasks occured( task x, task y, task z), on the 05/06/05 2
tasks occured(task a, task y) etc I would like to count the report to say
total days reported = 2
 
V

Van T. Dinh

I interpret your question slightly different from Lynn's interpretation so I
come up with a different SQL.

Assuming that you have 3 Records for the same date 05/05/05 (one for each
task x, y & z), you need something like:

********
SELECT YearMonth, Count(DatesOfTask) As NoOfDatesWithTasksInMonth
FROM
(
SELECT DISTINCT DateOfTask,
Format(DateOfTask, "yyyy-mm") As YearMonth
FROM [Tracking]
)
GROUP BY YearMonth
********

HTH
Van T. Dinh
MVP (Access)
 
J

JOM

Thanks that was helpful, but this is what my reports is supposed to do

Month = May (Month group Level)
5/5/05 (date group level)
Task x
Task y
Task z
5/6/05
Task x
Task a

Total days reported in May = 2

Currently my in my report am having 5 days reported instead of 2


Van T. Dinh said:
I interpret your question slightly different from Lynn's interpretation so I
come up with a different SQL.

Assuming that you have 3 Records for the same date 05/05/05 (one for each
task x, y & z), you need something like:

********
SELECT YearMonth, Count(DatesOfTask) As NoOfDatesWithTasksInMonth
FROM
(
SELECT DISTINCT DateOfTask,
Format(DateOfTask, "yyyy-mm") As YearMonth
FROM [Tracking]
)
GROUP BY YearMonth
********

HTH
Van T. Dinh
MVP (Access)


JOM said:
I have a table named tracking with the following fields date and tasks. I
would like to count how many days in a month that the tasks occured. e.g. if
on the 05/05/05 3 tasks occured( task x, task y, task z), on the 05/06/05 2
tasks occured(task a, task y) etc I would like to count the report to say
total days reported = 2
 
V

Van T. Dinh

In Report, IIRC:

* Add a Calculated TextBox "txtCountDay" in the "Date Group Level" Footer
and set its ControlSource to:

= 1

(including the equal sign). Set its Visible Property to False.

* Add a Calculated TextBox in the "Month Group Level" Footer and set its
ControlSource to:

= Sum([txtCountDay])

This should give you the number of days with Tasks in the month.

HTH
Van T. Dinh
MVP (Access)
 
J

JOM

I tried as you said, but the = Sum([txtCountDay]) part does not work, when I
run the report, a the txtCountDay textbox pops up and requires me to input
data...
I appreaciate your help thanks...


Van T. Dinh said:
In Report, IIRC:

* Add a Calculated TextBox "txtCountDay" in the "Date Group Level" Footer
and set its ControlSource to:

= 1

(including the equal sign). Set its Visible Property to False.

* Add a Calculated TextBox in the "Month Group Level" Footer and set its
ControlSource to:

= Sum([txtCountDay])

This should give you the number of days with Tasks in the month.

HTH
Van T. Dinh
MVP (Access)





JOM said:
Thanks that was helpful, but this is what my reports is supposed to do

Month = May (Month group Level)
5/5/05 (date group level)
Task x
Task y
Task z
5/6/05
Task x
Task a

Total days reported in May = 2

Currently my in my report am having 5 days reported instead of 2
 
V

Van T. Dinh

OK. Try another method:

* Still use the same txtCountDay but set its RunningSum Property to "Over
Group"

* Set the ControlSource of the TextBox in the "Month Group Level" Footer to:

= [txtCountDay]

Set the Visible of this TextBox to Yes / True.

HTH
Van T. Dinh
MVP (Access)
 
J

JOM

Thanks alot that worked perfect!
JOM!

Van T. Dinh said:
OK. Try another method:

* Still use the same txtCountDay but set its RunningSum Property to "Over
Group"

* Set the ControlSource of the TextBox in the "Month Group Level" Footer to:

= [txtCountDay]

Set the Visible of this TextBox to Yes / True.

HTH
Van T. Dinh
MVP (Access)






JOM said:
I tried as you said, but the = Sum([txtCountDay]) part does not work, when I
run the report, a the txtCountDay textbox pops up and requires me to input
data...
I appreaciate your help thanks...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top