months on report

A

Alex

I'm trying to show on my report the names of the last 6
months.

When I use this
=Format((Year(Date()),Month(Date())-6,1),"mmm")
for the 6th before current month, it shows nothing.
When I use the following
=Format(Month(Date())-6,"mmm") it shows Dec (but it should
be Jan) and for the rest of months =Format(Month(Date())-
5,"mmm") ... it shows Jan.

Could you advise what formula I could use?

Thanks
 
J

John Spencer (MVP)

=Format(DateAdd("m",-6,Date()),"mmm")

Or

=Format(DateSerial(Year(Date()),Month(Date())-6,1),"mmm")

Your method was getting the Month number (1-12) and then subtracting from that.
That was giving you a date in December 1899 or January 1900, since dates are
just the number of days from ???December 30, 1899???
 
A

Alex

Thanks a lot, John.
It's working perfectly.
-----Original Message-----
=Format(DateAdd("m",-6,Date()),"mmm")

Or

=Format(DateSerial(Year(Date()),Month(Date())-6,1),"mmm")

Your method was getting the Month number (1-12) and then subtracting from that.
That was giving you a date in December 1899 or January 1900, since dates are
just the number of days from ???December 30, 1899???

.
 

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