Solved

Name Previous 3 months

Posted on 2013-01-02
4
281 Views
Last Modified: 2013-01-02
Hi All,

I was using the following to give me the months names of previous months.

<%=(MonthName((Month(Now())-2)))%>

However, this is not a good solution as now its Jan (1)

Is there a built in function I can use to display previous month etc?

Kind regards

A.

PS. This is in classic ASP
0
Comment
Question by:Abiel de Groot
4 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 38736323
Hi,

You could add 12 and use modulo

Not sure of it

=(MonthName((Month(Now())-2+12) mod 12))%

Regards
0
 
LVL 17

Accepted Solution

by:
Kent Dyer earned 500 total points
ID: 38736340
I think this is what you are looking for..

wscript.echo MonthName(Month(DateAdd("m",-2,Now())))

Open in new window


HTH,

Kent
0
 
LVL 5

Author Closing Comment

by:Abiel de Groot
ID: 38736359
That was it. Many thanks
0
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 38736375
Hi,

If you want to get month name of any date, or previous month of given date then, Please try the following:
This Month <%=MonthName(Now().Month)%> <br />
	Previous Month <%=MonthName(Now().AddMonths(-1).Month)%> <br />
	Previous to Previous Month <%=MonthName(Now().AddMonths(-2).Month)%> <br />

Open in new window


Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question