Current month IIf statement.

P

Pjdelchi

I am trying to run an IIf statement that will return a value of "Y" or "N"
for any records where the [settle-dt] occurs within the current month. I
found how to automate the results from the beginning of the month, but is
there a way to automate the statement below so that I will not have to
manually change the #6/1/2008# portion. In other words, how can I run this
query from this point onwithout having to bother with changing of the dates
in the future? All I need to know is what records have a [settle-dt] in the
current month. Thanks.


"Current Month?: IIf([settle-dt]>Date()-Day(Date()) And
[settle-dt]<#6/1/2008#,"Y","N")"
 
M

Michel Walsh

DateSerial( Year(now), Month(now)+1, 1)

returns the first of the next month.



Vanderghast, Access MVP
 
J

John Spencer

Here are two methods.

CurrentMonth: IIF(Format(Format(Date(),"yyyymm") =
Format([Settle-dt],"yyyymm"),"Yes","No")

Or

CurrentMonth: IIF([Settle-dt] Between
DateSerial(Year(Date()0,Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),"Yes","No")



'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top