Using IIf with Dates

G

Guest

My date data is formatted as short date (9/1/04). I have a grouped query by
month (9,10,11,12) using the Month format MonthName:Month([CreatedDate]). I
am trying to create an Iif statement to change the number to the name of the
month.

=IIf([MonthName]=9,"September",IIf([MonthName]=10,"October",IIf([MonthName]=11,"November",IIf([MonthName]=12,"December","Invalid month"))))

I keep receiving Error# when I run my report. I have even enclosed the month
number in "", i.e. "9".

If there is any easier way to format my month to show the month name in the
query, that would be helpful.
Thanks!
 
R

Rick B

Why not use the built in format function to pull the month name?

Format([CreatedDate],"mmmm")



Rick B


Pat Z. said:
My date data is formatted as short date (9/1/04). I have a grouped query by
month (9,10,11,12) using the Month format MonthName:Month([CreatedDate]). I
am trying to create an Iif statement to change the number to the name of the
month.
=IIf([MonthName]=9,"September",IIf([MonthName]=10,"October",IIf([MonthName]=
11,"November",IIf([MonthName]=12,"December","Invalid month"))))
 
G

Guest

That works great. Only problem is now, it is sorting alpha. I want it to show
September, October, November, December....ideas?

Rick B said:
Why not use the built in format function to pull the month name?

Format([CreatedDate],"mmmm")



Rick B


Pat Z. said:
My date data is formatted as short date (9/1/04). I have a grouped query by
month (9,10,11,12) using the Month format MonthName:Month([CreatedDate]). I
am trying to create an Iif statement to change the number to the name of the
month.
=IIf([MonthName]=9,"September",IIf([MonthName]=10,"October",IIf([MonthName]=
11,"November",IIf([MonthName]=12,"December","Invalid month"))))
I keep receiving Error# when I run my report. I have even enclosed the month
number in "", i.e. "9".

If there is any easier way to format my month to show the month name in the
query, that would be helpful.
Thanks!
 
R

Rick B

You may need to have both in your query (but uncheck the one that pulls the
numeric month) and make that your sort.


Pat Z. said:
That works great. Only problem is now, it is sorting alpha. I want it to show
September, October, November, December....ideas?

Rick B said:
Why not use the built in format function to pull the month name?

Format([CreatedDate],"mmmm")



Rick B


Pat Z. said:
My date data is formatted as short date (9/1/04). I have a grouped
query
by
month (9,10,11,12) using the Month format
MonthName:Month([CreatedDate]).
I
am trying to create an Iif statement to change the number to the name
of
the
=IIf([MonthName]=9,"September",IIf([MonthName]=10,"October",IIf([MonthName]=
11,"November",IIf([MonthName]=12,"December","Invalid month"))))
I keep receiving Error# when I run my report. I have even enclosed the month
number in "", i.e. "9".

If there is any easier way to format my month to show the month name
in
the
query, that would be helpful.
Thanks!
 
G

Guest

Thanks, that did it!

Rick B said:
You may need to have both in your query (but uncheck the one that pulls the
numeric month) and make that your sort.


Pat Z. said:
That works great. Only problem is now, it is sorting alpha. I want it to show
September, October, November, December....ideas?

Rick B said:
Why not use the built in format function to pull the month name?

Format([CreatedDate],"mmmm")



Rick B


My date data is formatted as short date (9/1/04). I have a grouped query
by
month (9,10,11,12) using the Month format MonthName:Month([CreatedDate]).
I
am trying to create an Iif statement to change the number to the name of
the
month.


=IIf([MonthName]=9,"September",IIf([MonthName]=10,"October",IIf([MonthName]=
11,"November",IIf([MonthName]=12,"December","Invalid month"))))

I keep receiving Error# when I run my report. I have even enclosed the
month
number in "", i.e. "9".

If there is any easier way to format my month to show the month name in
the
query, that would be helpful.
Thanks!
 

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