M
M.Anderson
I have a legacy database in Access (presently 2003), containing call logs.
There is a query that returns all calls that occurred within a specified time
frame -- however, I've just now noticed that it appears to contain an error,
which I'd like to fix: it always returns a range that's one day smaller than
whatever you asked for!
For example, if you specify 2/1/2006 to 2/3/2006, you will only get records
up to 2/2/2006. In order to get anything from 2/3, you need to ask for 2/4!
I believe that this is due to a mismatch between date formats -- one table
is "General Date" while another is "Short Date". For my purposes, the extra
information provided by the "General Date" format is irrelevant to this query.
However, I have limited rights on this database, and cannot easily access
the tables themselves, but I *can* edit the queries. Is there a way to write
a query to accurately return records from a date range without modifying the
tables & all the historical data they contain? I'd appreciate any thoughts
you folks might have!
The SQL I've got to work with is below:
-----begin-----
SELECT Count(qry_ClosedCalls.Call_ID) AS CountOfCall_ID,
Sum(IIf(qry_ClosedCalls!TrueHoursElapsed<24,1,0)) AS [24 or less], [24 or
less]/[CountOfCall_ID] AS [24 or less %],
Sum(IIf(qry_ClosedCalls!TrueHoursElapsed Between 25 And 48,1,0)) AS [24-48],
[24-48]/[CountOfCall_ID] AS [24-48 %],
Sum(IIf(qry_ClosedCalls!TrueHoursElapsed>48,1,0)) AS [48+],
[48+]/[CountOfCall_ID] AS [48+ %], Avg(qry_ClosedCalls.TrueHoursElapsed) AS
AvgOfTrueHoursElapsed
FROM qry_ClosedCalls, tbl_DateRange
WHERE (((qry_ClosedCalls.Call_Date)<[tbl_DateRange]![End_Date] And
(qry_ClosedCalls.Call_Date)>[tbl_DateRange]![Begin_Date]));
-----end-----
There is a query that returns all calls that occurred within a specified time
frame -- however, I've just now noticed that it appears to contain an error,
which I'd like to fix: it always returns a range that's one day smaller than
whatever you asked for!
For example, if you specify 2/1/2006 to 2/3/2006, you will only get records
up to 2/2/2006. In order to get anything from 2/3, you need to ask for 2/4!
I believe that this is due to a mismatch between date formats -- one table
is "General Date" while another is "Short Date". For my purposes, the extra
information provided by the "General Date" format is irrelevant to this query.
However, I have limited rights on this database, and cannot easily access
the tables themselves, but I *can* edit the queries. Is there a way to write
a query to accurately return records from a date range without modifying the
tables & all the historical data they contain? I'd appreciate any thoughts
you folks might have!
The SQL I've got to work with is below:
-----begin-----
SELECT Count(qry_ClosedCalls.Call_ID) AS CountOfCall_ID,
Sum(IIf(qry_ClosedCalls!TrueHoursElapsed<24,1,0)) AS [24 or less], [24 or
less]/[CountOfCall_ID] AS [24 or less %],
Sum(IIf(qry_ClosedCalls!TrueHoursElapsed Between 25 And 48,1,0)) AS [24-48],
[24-48]/[CountOfCall_ID] AS [24-48 %],
Sum(IIf(qry_ClosedCalls!TrueHoursElapsed>48,1,0)) AS [48+],
[48+]/[CountOfCall_ID] AS [48+ %], Avg(qry_ClosedCalls.TrueHoursElapsed) AS
AvgOfTrueHoursElapsed
FROM qry_ClosedCalls, tbl_DateRange
WHERE (((qry_ClosedCalls.Call_Date)<[tbl_DateRange]![End_Date] And
(qry_ClosedCalls.Call_Date)>[tbl_DateRange]![Begin_Date]));
-----end-----