Display prior month in a text box in an Access report?

A

Adriana

I have a report that will be based on different queries which I will insert
as subreports. For the month on the report, I need it to be one month prior
and current year. I read other user's questions in the community, but
nothing works. What is the date formula for something like this?
 
A

Adriana

"It" means that I will insert a text box with a date formula for one month
prior and the current year. An unbound text box, of course. Sorry for the
vague description.
 
F

fredg

I have a report that will be based on different queries which I will insert
as subreports. For the month on the report, I need it to be one month prior
and current year. I read other user's questions in the community, but
nothing works. What is the date formula for something like this?

To get the prior month and year from today's date is quite easy but
we're not mind readers.
How would any of us know what you've read or tried, so why possibly
give you the same information all over again?

Also, your post is not very clear.
Exactly what is the "it" in 'I need it to be one month prior....'?
 
F

fredg

"It" means that I will insert a text box with a date formula for one month
prior and the current year. An unbound text box, of course. Sorry for the
vague description.

OK, so you have a Date field (DateTime datatype) and you wish to
display just the Month Year previous to what ever that date is?

Let's display the month as a 3 character value, i.e. Jan Feb Mar etc.

= Format(DateAdd("m",-1,[DateFieldName]),"mmm yyyy")

will display as Jan 2007 if the date value was anytime in February
2007.

Change [DateFieldName] to whatever the actual name of your date field
is.

If you want to show the month previous to the current month, then you
would use:

= Format(DateAdd("m",-1,Date()),"mmm yyyy")

will display Feb 2007 this month.

Note: the year will automatically be correct, i.e. a January 2007 date
will display as Dec 2006.

If you wish the month name in full then use:
"mmmm yyyy"

If you wish just the month as a number value, then use
"mm yyyy"

I hope this helps.
 
A

Adriana

Thank you very much, this formula worked the best: =
Format(DateAdd("m",-1,Date()),"mmm yyyy")
I had something similar from a query I used, but it was too complicated and
quite longer and I kept coming up with an error. You simplified it for me, so
now I understand the order. Thanks again fredg!

fredg said:
"It" means that I will insert a text box with a date formula for one month
prior and the current year. An unbound text box, of course. Sorry for the
vague description.

OK, so you have a Date field (DateTime datatype) and you wish to
display just the Month Year previous to what ever that date is?

Let's display the month as a 3 character value, i.e. Jan Feb Mar etc.

= Format(DateAdd("m",-1,[DateFieldName]),"mmm yyyy")

will display as Jan 2007 if the date value was anytime in February
2007.

Change [DateFieldName] to whatever the actual name of your date field
is.

If you want to show the month previous to the current month, then you
would use:

= Format(DateAdd("m",-1,Date()),"mmm yyyy")

will display Feb 2007 this month.

Note: the year will automatically be correct, i.e. a January 2007 date
will display as Dec 2006.

If you wish the month name in full then use:
"mmmm yyyy"

If you wish just the month as a number value, then use
"mm yyyy"

I hope this helps.
 

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