Results 1 to 8 of 8

Thread: month function

  1. #1
    Join Date
    Jan 2010
    Posts
    32

    Unanswered: month function

    I am trying to write a function to look at a date field that has a format of:1/21/2010 and change the numerical month to an abbreviated textual month such as: Jan.

    "When I run the query, it gives me an eror of " wrong number of arguments used with function in query expression 'datetomonth([obdate])'

    Here is the function:
    Public Function datetomonth()
    MonthName(1, True)
    monthname(2, True)
    monthname(3, True)
    monthname(4, True)
    monthname(5, True)
    monthname(6, True)
    monthname(7, True)
    monthname(8, True)
    monthname(9, True)
    monthname(10, True)
    monthname(11, True)
    monthname(12, True)


    End Function

    They are all in red too..which makes me think I did something wrong.

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    you haven't told datetomonth() about any arguments it's supposed to accept...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jan 2010
    Posts
    32
    I am pretty new at this....

    Aren't the arguments underneath?

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Teddy appears to be offline. No, those aren't the arguments. Here's a very basic primer, but it shows where the arguments should be:

    Function how-to
    Paul

  5. #5
    Join Date
    Jan 2010
    Posts
    32
    Thanks Baldy,

    That makes sense that I need something between the (). What argument would I need for the mission I am trying to accomplish?

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    This is a situation I wouldn't bother writing a function for. Why, when the MonthName function is already doing it for you (as would the Format function):

    MonthName(Month(obdate),True)
    Paul

  7. #7
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I should have added that the logical thing to pass would be the date, amending your function to accept it and return the month. But again, I wouldn't bother. You're writing a function that does nothing more than the built-in function does.
    Paul

  8. #8
    Join Date
    Jan 2010
    Posts
    32
    Thanks Paul,

    I will shift my thinking. I hate doing extra work!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •