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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a global

Status
Not open for further replies.

swhitten

Technical User
Sep 3, 2002
191
US
What's wrong with this?

="MTD: "+MonthName(Month(Globals.ExecutionTime)-1)

I am trying to return the name of the month that is one month prior to the current month.

Will the above work? Will it work in January, too, where the previous month can't be calculated as the month number -1? Example: the month prior to March can be calculated as 3-1. But in January 1-1 doesn't equal 12.

Thanks in advance!
 
To get the previous month, you can use DateAdd.
Example: =DateAdd(DateInterval.Month, -1, Globals!ExecutionTime)

I don't know of a built-in function to get the month name, though.
 
Can you not just use Format(date,"mmm") to get the month name ?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top