Query Date Parameter Month (1 Viewer)

SP_Brandon

New member
Local time
Today, 05:08
Joined
Jul 4, 2020
Messages
4
Hi Friends! I need some assistance with date parameters in a query! A Google search returned using Month(Date()). I also tried Month(Now()) and Month(Today)). None of these worked. Then, I found a website that provided the following formula: Between DateSerial(Year(Date()),Month(Date())-1,1) And DateSerial(Year(Date()),Month(Date())+1,0). However, that seems to pull a rolling month's worth of data. I need the current month. Please help! Thank you in advance!

Query - Date Parameter - Month.png
 

Isaac

Lifelong Learner
Local time
Today, 02:08
Joined
Mar 14, 2017
Messages
8,738
Code:
Where month([closed date])=month(today()) and year([closed date]) = year(today())

is one way
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:08
Joined
Oct 29, 2018
Messages
21,357
Hi. What is the data type of your [Closed Date] field? If it's a Date/Time, then I would also recommend using DateSerial().
 

Isaac

Lifelong Learner
Local time
Today, 02:08
Joined
Mar 14, 2017
Messages
8,738
@SP_Brandon
If your table values do not have a time value, here is something you can paste directly into the query design under your date field as criteria:
Code:
Between DateSerial(Year(Now()),Month(Now()),1) And DateAdd("d",-1,CDate(IIf(Month(Now())=12,1,Month(Now())+1) & "/1/" & IIf(Month(Now())=12,Year(Now())+1,Year(Now()))))

Better than what I first posted, optimization/speed-wise
 

SP_Brandon

New member
Local time
Today, 05:08
Joined
Jul 4, 2020
Messages
4
@SP_Brandon
If your table values do not have a time value, here is something you can paste directly into the query design under your date field as criteria:
Code:
Between DateSerial(Year(Now()),Month(Now()),1) And DateAdd("d",-1,CDate(IIf(Month(Now())=12,1,Month(Now())+1) & "/1/" & IIf(Month(Now())=12,Year(Now())+1,Year(Now()))))

Better than what I first posted, optimization/speed-wise

This worked perfectly! Thank you so much!
 

Users who are viewing this thread

Top Bottom