Quick question hopefully,
Is there a keyword that quickly changes the number of the Month into the correct name.
For example 1=January, 2=February?
Printable View
Quick question hopefully,
Is there a keyword that quickly changes the number of the Month into the correct name.
For example 1=January, 2=February?
Sorry if I missed the most important piece of information out...It's actually for ASP, and MonthName doesn't seem to work in ASP!
Sorry again!
:confused:
MonthName() not only works for me, I'm using it quite liberally.
'Course, I'm on W2K, so what is that, IIS5? Are you on an older server using an older version of VBScript?
Anyway... if you can't use MonthName(), you'll have to use a switched case.
I've put in the following...
but it comes up with the following errorCode:
if(thename="bob")then
tmptest=monthname(tmpday)
response.write tmptest & " is the test<BR>" & chr(13)
end if
We're using Windows 2000 with IIS5 so theres nothing wrong there then. Any more ideas anyone?Quote:
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'monthname'
/intranet/telephone/logcall/logcall.asp, line 72
What is tmpday? If it is a date, you will need to do this...
Code:strMonth = MonthName(Month(myDate))
tmpday is the number of the month. I've actually got it as tmpmonth so I don't know why I wrote tmpday!
ASP is not finding the function MonthName at all, rather than me putting in faulty values.
If I do this on a page, all by its lonesome, it works.
I don't know how to check for libraries or such. *shrug* I have IIS 5 on W2K Pro with VS 6 Enterprise.Code:<%=MonthName(1)%>
According to this page:
http://msdn.microsoft.com/scripting/...nformation.htm
MonthName() was introduced in VBScript 2.0. I am hoping you have a newer version of VBScript then 2.
Have you tried doing <% = MonthName(1) %> as mentioned above?
Yep...that worked. So now I must go back to my code to understand why its not working!
Anyone got any ideas...my codes above, but I've now got the line as
because I thought it might be something to do with integers etc.Code:tmptest=MonthName(int(tmpday))
Cheers for everyones help.
I did the following code on PWS on NT 4 and got the result January. As you can see, I made tmpMonth equal to the string 1. Using CInt() I changed it to an int and it worked:
On a side note, even when I did not use CInt, it still worked:Code:tmpMonth = "1"
Response.Write MonthName(CInt(tmpMonth))
So you may want to make sure that tmpMonth is indeed equal to 1 by doing a Response.Write.Code:tmpMonth = "1"
Response.Write MonthName(tmpMonth)
HTH.
Richy,
Invalid Procedure Call or Argument indicates that you're passing it an invalid argument, as in your tmpMonth is not what you think it is. MonthName will accept a variant for the first argument, meaning MonthName("1"), MonthName(1), MonthName(CLng(1)), MonthName(Int(True) * -1) will all return January (of course the latter is kinda dumb, but it works). There MUST be something wrong with your tmpMonth, I would try MonthName(Month(tmpMonth)) or just Response.Write tmpMonth to see exactly what it is.
Tanner
Yes indeed, it was my quality code which was passing a blank variable! My apologies and I will now go and sit in the corner with a big dunce hat on!!!