Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display the previous month as text without DateAdd?

Status
Not open for further replies.

stormtrooper

Programmer
Apr 2, 2001
266
CA
I may be missing something really easy here (blanking out maybe), but how do you display the previous month as text?

So I want to somehow turn this:

month(currentdate)-1 (which equals 6.00)

to:

June
 
You could do it this way as well. Create a formula like this if you don't have monthname.

IF MONTH(CURRENTDATE)-1 = 6 THEN
"June"
ELSE IF
MONTH(CURRENTDATE)-1 = 7 THEN
"July"
ELSE IF
MONTH(CURRENTDATE)-1 = 8 THEN
"August"

You would do this for all 12 months and that should work as well.

 
Got it, I knew I've done this before.

totext(date(year(currentdate), month(currentdate) - 1, day(currentdate)), 'MMMM')
 
From the CD whitepaper:


StringVar Array X:= ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
Numbervar Y:= Month(currentdate) - 1;
X[Y];

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top