|
-
Jun 15th, 2001, 07:36 AM
#1
Thread Starter
Hyperactive Member
Month String From Number
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?
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Jun 20th, 2001, 09:50 AM
#2
Thread Starter
Hyperactive Member
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!
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Jun 20th, 2001, 11:02 AM
#3
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 21st, 2001, 04:47 AM
#4
Thread Starter
Hyperactive Member
I've put in the following...
Code:
if(thename="bob")then
tmptest=monthname(tmpday)
response.write tmptest & " is the test<BR>" & chr(13)
end if
but it comes up with the following error
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'monthname'
/intranet/telephone/logcall/logcall.asp, line 72
We're using Windows 2000 with IIS5 so theres nothing wrong there then. Any more ideas anyone?
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Jun 21st, 2001, 08:28 AM
#5
Frenzied Member
What is tmpday? If it is a date, you will need to do this...
Code:
strMonth = MonthName(Month(myDate))
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 21st, 2001, 10:50 AM
#6
Thread Starter
Hyperactive Member
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.
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Jun 21st, 2001, 10:57 AM
#7
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jun 21st, 2001, 07:25 PM
#8
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?
-
Jun 22nd, 2001, 03:16 AM
#9
Thread Starter
Hyperactive Member
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
Code:
tmptest=MonthName(int(tmpday))
because I thought it might be something to do with integers etc.
Cheers for everyones help.
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Jun 22nd, 2001, 04:32 PM
#10
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:
Code:
tmpMonth = "1"
Response.Write MonthName(CInt(tmpMonth))
On a side note, even when I did not use CInt, it still worked:
Code:
tmpMonth = "1"
Response.Write MonthName(tmpMonth)
So you may want to make sure that tmpMonth is indeed equal to 1 by doing a Response.Write.
HTH.
-
Jun 22nd, 2001, 08:21 PM
#11
Invalid Procedure Call or Argument.
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
-
Jun 25th, 2001, 03:38 AM
#12
Thread Starter
Hyperactive Member
Indeed
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!!!
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|