IIf statement Convert Dates to Months

Dona

Registered User.
Local time
Today, 23:09
Joined
Jun 27, 2002
Messages
55
I want to convert my dates to months so I added the statement below in the Field section of my query. It is not working. What am doing wrong?


Month:IIf([dateActivity]>=7/1/2004,IIf([dateActivity]>=8/1/2004,IIf([dateActivity]>=9/1/2004,IIf([dateActivity]>=10/1/2004,IIf([dateActivity]>=11/1/2004,IIf([dateActivity]>=12/1/2004,IIf([dateActivity]>=1/1/2005,IIf([dateActivity]>=2/1/2005,IIf([dateActivity]>=3/1/2005,IIf([dateActivity]>=4/1/2005,IIf([dateActivity]>=5/1/2005,IIf([dateActivity]<=6/30/2005,”June”,”May”),”April”),”March”),”February”),”January”),”December”),”November”),”October”),”September”),”August”),”July”))



Thank you.
 
Dona said:
I want to convert my dates to months so I added the statement below in the Field section of my query. It is not working. What am doing wrong?


Month:IIf([dateActivity]>=7/1/2004,IIf([dateActivity]>=8/1/2004,IIf([dateActivity]>=9/1/2004,IIf([dateActivity]>=10/1/2004,IIf([dateActivity]>=11/1/2004,IIf([dateActivity]>=12/1/2004,IIf([dateActivity]>=1/1/2005,IIf([dateActivity]>=2/1/2005,IIf([dateActivity]>=3/1/2005,IIf([dateActivity]>=4/1/2005,IIf([dateActivity]>=5/1/2005,IIf([dateActivity]<=6/30/2005,”June”,”May”),”April”),”March”),”February”),”January”),”December”),”November”),”October”),”September”),”August”),”July”))



Thank you.

I think the problem is instead of having all the months at the end you should have following the IIF it belongs too.
exp


IIf([dateActivity]>=7/1/2004, "June" IIf([dateActivity]>=8/1/2004, "July"...
 
I tried your suggestion; however, now I'm receiving an error message:

The expression you entered is missing a closing parenthesis,bracket or vertical bar.

I added a parenthesis at the end.


Any suggestions?
 
Dona said:
I tried your suggestion; however, now I'm receiving an error message:

The expression you entered is missing a closing parenthesis,bracket or vertical bar.

I added a parenthesis at the end.


Any suggestions?

Make sure you have enough closed parens at the end of the statement. Count the open parens in your line and then make sure you have that many at the end.
 
Is there a reason not to simplify it to:

ActivityMonth: Format([dateActivity],"mmmm")
 
Last edited:
Thanks Paul.

This worked much better than my IIF statement. I still couldn't get IIF statement to work.

Thanks for all the time I saved.

Have a good weekend!
 

Users who are viewing this thread

Back
Top Bottom