Link to home
Create AccountLog in
Avatar of Abiel de Groot
Abiel de GrootFlag for Spain

asked on

Name Previous 3 months

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
Avatar of Rgonzo1971
Rgonzo1971

Hi,

You could add 12 and use modulo

Not sure of it

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

Regards
ASKER CERTIFIED SOLUTION
Avatar of Kent Dyer
Kent Dyer
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Abiel de Groot

ASKER

That was it. Many thanks
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