Date value in page header for a year ago (month and year only)

G

Guest

Hi,

I am trying create a report that shows monthly sales for last month and for
a year ago. So if I ran this today it would show April 2005 and April 2004
sales. If I ran in on June 1st it would show May 2005 and May 2004 sales. I
have the queries down but I am trying to create the column label name in the
page header user a text box. I want the column label to read the month and
year only. I already created a column name for last months sales which is:

Last Month
=Format(DateAdd("m",-1,Date()),"mmmm") & " " & Format(Date(),"yyyy")

I want to create a column header for monthly sales year ago. So I want it
to read April 2004 and then have it change to May 2004 when June first rolls
around. Here is what I have but I am getting error messages:

=Format(DateAdd("m",-1,Date()),"mmmm") & " " &
Format(dateadd(“yâ€,-1,Date(),"yyyy"))

Can someone help?

Thanks,
 
W

Wayne Morgan

=Format(DateAdd("m",-1,Date()),"mmmm") & " " &
Format(dateadd("y",-1,Date(),"yyyy"))

A couple of things, "y" is Day of Year, you need "yyyy". Also, a parenthesis
location in the year part. You also had "curly quotes" around the y, as if
they had been pasted from a word processor. I don't know if that would cause
you a problem or not.

=Format(DateAdd("m",-1,Date()),"mmmm") & " " &
Format(dateadd("yyyy",-1,Date()),"yyyy")
 
G

Guest

Wayne,

Thanks for your help. I pasted your code into a text box in the page header
of my report. I got an error that said "The expression you entered has a
function containing the wrong number of arguments". Any idea what the error
message means?

Thanks,
 
W

Wayne Morgan

Please copy and paste what you have in the textbox's control source into a
message.
 
G

Guest

Here is the code.

Thanks,

=Format(DateAdd("m",-1,Date()),"mmmm") & " " &
Format(dateadd("y",-1,Date(),"yyyy"))
 
W

Wayne Morgan

You didn't correct the problem with the parenthesis in the second Format
statement or change the y to yyyy. The equation should read:

=Format(DateAdd("m",-1,Date()),"mmmm") & " " &
Format(dateadd("yyyy",-1,Date()),"yyyy")
 

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