Results 1 to 12 of 12

Thread: Month String From Number

  1. #1

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353

    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."

  2. #2

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    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."

  3. #3
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140


    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.

  4. #4

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    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."

  5. #5
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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.

  6. #6

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    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."

  7. #7
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    If I do this on a page, all by its lonesome, it works.

    Code:
    <%=MonthName(1)%>
    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.

  8. #8
    CMangano
    Guest
    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?

  9. #9

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    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."

  10. #10
    CMangano
    Guest
    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.

  11. #11
    NeoZ018
    Guest

    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

  12. #12

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353

    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
  •  



Click Here to Expand Forum to Full Width