A
Allie
Hi Experts,
I have a databse of employee absences. I am trying to query (per badge
number/employee) the sum of days absent, the earliest & latest dates, and
then return the number of days between the two.
This is what I have:
SELECT Records.BADGE, Sum(Records.DAYS) AS SumOfDAYS, Min(Records.DATE) AS
MinOfDATE, Max(Records.DATE) AS MaxOfDATE,
Abs(DateDiff('d',[MINOFDATE],[MAXOFDATE])) AS DIFFERENCE
FROM Records
GROUP BY Records.BADGE;
If the MaxofDATE and MinofDATE are in the same year, everything works
perfectly. But in this example:
Absences
2/5/08
10/5/08
1/5/09
The MaxofDATE should be 1/5/09
The MinodDATE shouldbe 2/5/08
The query however is returning 1/5/09 and min and 10/5/08 as max
Seems like it is looking at the MONTH and not including the year. Any ideas
why?
I have a databse of employee absences. I am trying to query (per badge
number/employee) the sum of days absent, the earliest & latest dates, and
then return the number of days between the two.
This is what I have:
SELECT Records.BADGE, Sum(Records.DAYS) AS SumOfDAYS, Min(Records.DATE) AS
MinOfDATE, Max(Records.DATE) AS MaxOfDATE,
Abs(DateDiff('d',[MINOFDATE],[MAXOFDATE])) AS DIFFERENCE
FROM Records
GROUP BY Records.BADGE;
If the MaxofDATE and MinofDATE are in the same year, everything works
perfectly. But in this example:
Absences
2/5/08
10/5/08
1/5/09
The MaxofDATE should be 1/5/09
The MinodDATE shouldbe 2/5/08
The query however is returning 1/5/09 and min and 10/5/08 as max
Seems like it is looking at the MONTH and not including the year. Any ideas
why?