+ Reply to Thread
Results 1 to 4 of 4

Function to Output Current Month and Year

  1. #1
    Registered User
    Join Date
    02-20-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010
    Posts
    30

    Function to Output Current Month and Year

    I was wondering if there was a function which will output the the current month and year for example "April 2012" preferably "April_2012". I have tried using the Now() function and then formating another cell to MMMM_YYY but when I call that cell in VBA it outputs "4/13/2012 12:23PM" (full current time). Any idea on how to do this?

    Thanks in advance!
    Last edited by cg0789; 04-13-2012 at 01:47 PM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Function to Output Current Month and Year

    Try

    =TEXT(TODAY(),"mmmm_yyyyy")

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Function to Output Current Month and Year

    Hello cg0789 ,

    VBA will always display a date according to the system's short date setting. You can use the VBA Format statement to change the output of the date. Here is an example
    Please Login or Register  to view this content.

    NOTE:
    Internally, all dates are numbers. Excel and VBA allow the number output to be formatted in a way understood by people. The format statement returns a String and not a Date. Because this is custom date format, Neither Excel nor VBA will not be able to convert this string to date and can not be used with Date functions.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    02-20-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Function to Output Current Month and Year

    Leith, that is exactly what I needed, thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1