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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count days

Status
Not open for further replies.

ttuser4

MIS
Jun 19, 2008
147
0
0
CA
hi, i want to count how many days employees worked within last 30 days (if they qualify for statutory holiday) but my query gives me empty record set:

SELECT Query3A.EMPID, Query3A.FULL_NAME, Count(Query3A.WDAYS) AS WDS
FROM Query3A
WHERE (((Query3A.WDAYS) Between (Now()-30) And Now()))
GROUP BY Query3A.EMPID, Query3A.FULL_NAME;

query without 'where' gives me the correct number:
SELECT Query3A.EMPID, Query3A.FULL_NAME, Count(Query3A.WDAYS) AS WDS
FROM Query3A
GROUP BY Query3A.EMPID, Query3A.FULL_NAME;

EMPID FULL_NAME WDS
0154 BILLINGSLEY, CHRIS 8
0220 GIBSON, BRENT 4
0262 SCHWARZ, STEVEN 10
...

or
SELECT Query3A.EMPID, Query3A.FULL_NAME, Count(Query3A.WDAYS) AS WDS, Query3A.WDAYS
FROM Query3A
GROUP BY Query3A.EMPID, Query3A.FULL_NAME, Query3A.WDAYS;

EMPID FULL_NAME WDS WDAYS
0154 BILLINGSLEY, CHRIS 1 June 15, 2012
0154 BILLINGSLEY, CHRIS 1 June 8, 2012
0154 BILLINGSLEY, CHRIS 1 June 9, 2012
0220 GIBSON, BRENT 1 June 12, 2012
0220 GIBSON, BRENT 1 June 13, 2012
0220 GIBSON, BRENT 1 June 14, 2012
0220 GIBSON, BRENT 1 June 15, 2012
0262 SCHWARZ, STEVEN 1 June 1, 2012
0262 SCHWARZ, STEVEN 1 June 10, 2012
0262 SCHWARZ, STEVEN 1 June 2, 2012
...

any help, please?
 
hi,

What is the data type of WDAYS?
Code:
SELECT EMPID, FULL_NAME, Count(*) AS WDS
FROM Query3A
WHERE WDAYS Between Date()-30 And Date()
GROUP BY EMPID, FULL_NAME;

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
WDAYS is date format (long) like in here:

SELECT Query3A.EMPID, Query3A.FULL_NAME, Count(Query3A.WDAYS) AS WDS, Query3A.WDAYS
FROM Query3A
GROUP BY Query3A.EMPID, Query3A.FULL_NAME, Query3A.WDAYS;

EMPID FULL_NAME WDS WDAYS
0154 BILLINGSLEY, CHRIS 1 June 15, 2012
0154 BILLINGSLEY, CHRIS 1 June 8, 2012
0154 BILLINGSLEY, CHRIS 1 June 9, 2012
0220 GIBSON, BRENT 1 June 12, 2012
0220 GIBSON, BRENT 1 June 13, 2012
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top