Your assumption is correct. I do not need the time component. Let me
give
you a clearer picture. I am exporting my Outlook calendar to an Access
database. qCalendar gives me the appropriate information based on
Categories:
SELECT tblCalendar.StartDate, tblCalendar.StartTime,
tblCalendar.EndDate,
tblCalendar.EndTime, tblCalendar.Categories, tblCalendar.Subject,
tblCalendar.Description, tblCalendar.Location
FROM tblCalendar
WHERE (((tblCalendar.Categories)<>"Personal" And
(tblCalendar.Categories)<>"Holiday" And
(tblCalendar.Categories)<>"Birthday"
And (tblCalendar.Categories)<>"Phone Calls" And
(tblCalendar.Categories)<>"Business"));
qCalendar returns data that looks like:
StartDate Categories Subject StartTime EndDate EndTime Description
Location
1/3/2007 Recruiting Int: Marc Weinstien 1 ### ### #### 1:00:00
PM 1/3/2007 2:00:00 PM DF
1/3/2007 Recruiting Int: Greg Perc. 1 ### ### #### 2:30:00
PM 1/3/2007 3:30:00 PM "From Lake Villa
" DF
1/2/2007 Securities Mark J. 6:00:00 PM 1/2/2007 6:45:00 PM "Rollover
$114 from Hos.
$ 12K from bank
" Gur
{sorry for the long lines}
I am looking for qKT test to:
1) bring back a 7 day window of appointments for qCalendar
2) return a value KT (appointments) which are the total appointments
set
during the 7 day window.
You see, the idea is a report can eventually be printed that answers
the
question, "How many appointments do I have over the next 7 days?"
Right now qKT test looks like:
SELECT CVDate([StartDate]) AS TheDate, (SELECT Count([Categories]) AS
TheCount FROM qCalendar AS Dupe WHERE Dupe.StartDate >=
CVDate([StartDate]) AND Dupe.StartDate < CVDate([StartDate]) + 8) AS
WeekAheadCount
FROM qCalendar
GROUP BY CVDate([StartDate]);
and returns 70 lines that look like:
TheDate WeekAheadCount
1/2/2007 92
1/3/2007 92
1/4/2007 92
.
.
.
4/1/2007 92
4/3/2007 92
4/6/2007 92
4/7/2007 92
4/9/2007 92
4/10/2007 92
4/12/2007 92
So, it is not giving me the 7d window, and I have no idea what it means
by
WeekAheadCount being 92.
I know this is a lot of info, but now you have everything. Hopefully
the
problem was not simply insufficient data.
Thanks for helping!
:
Ah: I assumed you were trying to lose the time component.
Try CVDate() instead of DateValue, around *every* instance of
StartDate.
The fields all get to my database as text, thus the DateValue
function.
But
why the 269 value? If I could even get the number of appointment
per
day
for
every day returned by qCalendar I could get by just fine by changing
qCalendar to a 7 day window instead of a 6 month window. So, the
main
problem is counting the number of appointments per day.
Thoughts?
:
It should give you a 7-day window: greater than or equal to the
appointment
date, and less than the appointment date + 8 days -- that's a 7 day
period.
I guess something else must be going on, such as not narrowing to
the
desired person, or a confusion of data types (i.e. the fields are
not
real
date/time fields, or they are calculated fields Access is confused
about.)
The result of:
SELECT DateValue([StartDate]) AS TheDate, (SELECT
Count([Categories])
AS
TheCount FROM qCalendar AS Dupe WHERE Dupe.StartDate >=
DateValue([StartDate]) AND Dupe.StartDate <
DateValue([StartDate]) +
8)
AS
WeekAheadCount
FROM qCalendar
GROUP BY DateValue([StartDate]);
gives me two col. The first col, TheDate, gives me the dates
retrieved
via
qCalendar - works fine. The second col, WeekAheadCount, is
telling
me
I
have
269 {appointments?} for each date. I'm not sure what the 269 is,
but I
was
expecting to see the number of appointments per date. It also
does
not
appear to be giving a 7 day window. qCalendar is from 1/1/2007
to
7/1/2007
(this query will be used for other things). I was expecting the
query
we
are
working on to narrow that down to a 7 day window and count the
number
of
appointments per day. It seems like we are getting closer.
Thanks for your continued support.
:
Use a subquery.
For each date that you have an appointment, this query gives you
the
number
of appointments in the coming 7 days:
SELECT DateValue([tblCalendar].[StartDate]) AS TheDate,
(SELECT Count([AppointmentID]) AS TheCount
FROM tblCalendar AS Dupe
WHERE Dupe.StartDate >= DateValue([tblCalendar].[StartDate])
AND Dupe.StartDate < DateValue([tblCalendar].[StartDate]) +
8)
AS WeekAheadCount
FROM tblCalendar
GROUP BY DateValue([StartDate]);
If subqueries are new, see:
http://allenbrowne.com/subquery-01.html
I have tblCalendar (an export for Outlook). I am trying to
find
the
number
of appointments within a 7 day window based on the start date
of
the
appointment. I am converting the start date by Start Date:
CDate([StartDate]). The query is bring back the apporpriate
record
based
on
"Category" criteria and ">=Date() AND <=Date()+7", however, I
would
like
to
have "KT" be the number of appointments scheduled to take
place
on
CDate([StartDate]). I tried several approaches but always get
strange
numbers such as 395 appointment on a given day when using:
KTs:
DCount((FormatDateTime(CDate([StartDate]),0)),"qCalendar",FormatDateTime(CDate([StartDate]),0)>=Date())
in my query. (qCalendar filters out all non-biz related
appointments
from tblCalendar.)