Results 1 to 5 of 5
  1. #1
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35

    MonthDate Function

    I am trying to do a Totals query and group on a date (mm/dd/yy) field by Month Name. It is grouping by Month number right now. I tried to use the MonthName function, but I really don't understand what should be in there. What criteria should I enter ? What does the abbreviate mean ?



    MonthName(«month», «abbreviate»)

    The field I am grouping on is called Actual Date

    Thanks in advance !

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    See the following link for info about MonthName() function: https://docs.microsoft.com/en-us/off...hname-function

    Using the following expression in the first line of a column in query design: Mth: MonthName(Month([Actual Date]),-1)
    will give a column in the query, headed "Mth", that returns an abbreviated value for the name of the month in [Actual Date]
    To return the name of the month in full, use: Mth: MonthName(Month([Actual Date]),0)
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Thank you Bob (once again) !

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I've just seen that you were also asking about using criteria.
    If criteria is applied to the calculated field that I suggested earlier then it would need to be in the format as the month being returned. eg "Jan" if abbreviated. "January" id not.
    Alternatively, you could have another column MthNum: Month([Actual Date]) in which the criteria needed would be the numerical value of the month. eg 1 would return January records.

    PS
    Thank you for your kind words in your reputation comments

    EDIT:
    The column being used for the criteria does not need to be shown in the dataset returned
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Join Date
    Apr 2017
    Posts
    1,681
    My advice is: Definitely have month number returned by query! Use month number for grouping AND FOR ORDERING (Ordering results by month name will give you monthly results disordered). You can have month name returned optionally, and display it e.g. in report instead of month number, but use it for display only!

    And this is applicable only when your query will return data for a single year only! In case results for months over several year are returned, I myself as a rule use a month number as an integer in format yyyymm.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 15
    Last Post: 10-17-2018, 09:26 PM
  2. Replies: 15
    Last Post: 05-31-2017, 02:10 PM
  3. Replies: 2
    Last Post: 02-26-2017, 11:31 AM
  4. Replies: 3
    Last Post: 03-04-2016, 10:36 AM
  5. Replies: 8
    Last Post: 11-04-2014, 10:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums