VBScript Month Name

Hi Experts,
The following returns the month as a number, e.g. 8 for August

<%=Request.Form("myMonth")%>

How could I display the month name instead of a number.

Thank you for your help
romsomAsked:
Who is Participating?
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
use the MonthName function() - http://www.w3schools.com/vbscript/func_monthname.asp

<%=MonthName( Request.Form("myMonth") )%>
0
 
romsomAuthor Commented:
Thank you very much Big Monty.
Nice to see you!
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
keep in mind if it's not a valid number, it'll through an error, so you may want to do some error checking:

<%
   monthNum = Request.Form("myMonth")
   if not isNumeric( monthNum ) then 
       monthNum = Month( Now )     '-- default to current month
    elseif monthNum < 1 or monthNum > 12 then
       monthNum = Month( Now )     '-- default to current month
   end if

Response.Write MonthName( monthNum )
%>

Open in new window

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you're very welcome! have a swell weekend :)
0
 
romsomAuthor Commented:
It's working fine because I submit from a dropdown where the month numbers are hard coded.
Have fun this weekend!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.