Date function

S

Sharad Gupta

Friends

I need a date simple date function that would append the coming month
value in my current month

like
monthname(month(date)) : gives me current month in string
i need next month , a string value added to it.
The problem I am facing is this..
prevmon = monthname(month(date) + 1)
this is last month of the year, and when I append 1 to this function,
it gives error since dec is the last month of the year. It is not
appending itself to Jan2005.


It works fine for getting the string value for last month iei
prevmon = monthname(month(date) - 1)

Pls help
 
B

Bob Barrows [MVP]

Sharad said:
Friends

I need a date simple date function that would append the coming month
value in my current month

like
monthname(month(date)) : gives me current month in string
i need next month , a string value added to it.
The problem I am facing is this..
prevmon = monthname(month(date) + 1)
this is last month of the year, and when I append 1 to this function,
it gives error since dec is the last month of the year. It is not
appending itself to Jan2005.


It works fine for getting the string value for last month iei
prevmon = monthname(month(date) - 1)

Pls help

monthname(month(dateadd("mm",1,date)))

Look up the dateadd function in the vbscript documentation. If you don't
have the documentation, you can download it from here:
http://www.microsoft.com/downloads/...48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en

Bob Barrows
 
R

Ray Costanzo [MVP]

So, if it's December, you want January, correct?

Function NextMonthName(d)
dOneMonthFromD = DateAdd("m", 1, d)
dNextMonth = Month(dOneMonthFromD)
NextMonthName = Monthname(dNextMonth)
End Function

Or the abbreviated version:

Monthname(Month(DateAdd("m", 1, yourDate)))

Ray at work
 
S

Sharad Gupta

Thanks a lot ray

Monthname(Month(DateAdd("m", 1, yourDate))) :
it solved my problem
 

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

Members online

Forum statistics

Threads
474,163
Messages
2,570,897
Members
47,434
Latest member
TobiasLoan

Latest Threads

Top