filtering only current month values (1 Viewer)

Ravi Kumar

Registered User.
Local time
Today, 14:13
Joined
Aug 22, 2019
Messages
162
Hi all ,
I have a query in which I need to filter only current month records , but using Month(now()) it is not filtering .
Below is my SQL , can you tell me how to do this?
SQL:
SELECT [OT and Absenteeism by month].[Date of Entry By Month], [OT and Absenteeism by month].[Sum Of OT (hrs)], [OT and Absenteeism by month].[Sum Of Absentees (hrs)], [OT and Absenteeism by month].[Count Of Master_table]
FROM [OT and Absenteeism by month];
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:43
Joined
Sep 21, 2011
Messages
14,037
I do not see you using Month(now()) ?

However, it would be along the lines of

Code:
Month([OT and Absenteeism by month].[Date of Entry By Month]) = Month(Now())
or

Code:
Month([OT and Absenteeism by month].[Date of Entry By Month]) = Month(Date)

HTH
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:43
Joined
Aug 11, 2003
Messages
11,696
you will probably need to add something about years as well.

and erm, spaces in column and table names :(
 

Ravi Kumar

Registered User.
Local time
Today, 14:13
Joined
Aug 22, 2019
Messages
162
you will probably need to add something about years as well.

and erm, spaces in column and table names :(
Sorry , I try to avoid them ny using underscore but sometimes I forget ..will correct them
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:43
Joined
Feb 19, 2002
Messages
42,970
INMNSHO, underscores are as bad as spaces but Access likes them. I prefer CamelCase. Rather than separating words with spaces or underscores, just capitalize the first letter of each. It's pretty easy to read and less to type. I also hate to have to shift to type an underscore. When I was writing in COBOL, the separator was the dash and since all code was upper case, we didn't have the option of CamelCase.

I only use the_underscore when I want to emphasize the separation.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:43
Joined
Oct 29, 2018
Messages
21,357
Hi Ravi. If by "current month" you mean from the 1st to the end of this month, then I prefer using a WHERE clause similar to this:

Code:
...WHERE DateField Between DateSerial(Year(Date()),Month(Date()),1) And DateSerial(Year(Date()),Month(Date())+1,0)
 

Users who are viewing this thread

Top Bottom