Results 1 to 3 of 3

Thread: MonthName Function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Oak Creek, WI, USA
    Posts
    92

    MonthName Function

    I am trying to get MonthName to give me the previous month by doing this: MonthName((DatePart"m", Date(), 1)-1) but I am getting an illegal procedure call or argument error message. Can anyone help me with the syntax or can I even do this? Thanks.

    casox
    GOD is One - His name is Jesus
    LOVE Truth - HATE Evil - CRUSH the Serpent's Head

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Code:
    m = Month(Date() - 30)
    Response.write(MonthName(m))
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    A further explanation: The reason it returns an error.... January's month is 1.. so when you 1-1, you end up with 0... Since no month is 0, the error happens.
    You could try memnoch's approach, but that could lead to some problems as not all months are 30 days.... or add a simple check that will set the month to 12 when it is 0.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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