+ Reply to Thread
Results 1 to 4 of 4

I can't get the Month to extract from a date

  1. #1
    Registered User
    Join Date
    09-10-2015
    Location
    Caringbah, NSW, Australia
    MS-Off Ver
    Office 365
    Posts
    27

    Unhappy I can't get the Month to extract from a date

    I have a date (formatted as dd-mmm-yy) in cell P1 - eg 31-Jul-19

    I want to get the end-of month from that cell BUT want only the month.

    My task is to lookup the end of a selected month from a table of values and return only the related value.

    The table is foreign exchange rate, with daily data entered. The table has a column that calculates the monthly average (one column as a running average and one column with only the actual average for that month)

    I have tried the =Month($p$1) where $p$1 is the current date [ =Now() ]. Does not want to know about the date! I enter, for example, 31/7/19 in cell P1 and this formula (after custom formatting mmmm) yields January!

    I have tried EOMONTH(Data($p$1) &"1") to see if I could get the end on month month for the date in $p$1 snd always get ERROR!

    What am I doing incorrectly and can anyone help with a solution that actually works?

    I have not attached the spreadsheet as it is over 17,000 lines long by 23 columns wide!

    Thanks in advance

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Business (Win 10 - Work) & MS 365 Subscription Insider (Win 10 - Home)
    Posts
    43,896

    Re: I can't get the Month to extract from a date

    Try this:

    =TEXT(EOMONTH($P$1,0),"mmmm")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  3. #3
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL (COVID allowing)
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,342

    Re: I can't get the Month to extract from a date

    Your problem is a combination of the MONTH function returning a number and the way Excel treats dates internally. Excel stores dates just as numbers, with '1' being 1st January 1900. For 31/7/19, MONTH returns the number '7'. Excel doesn't recognise this as a date, just as a number. So when you format it as a date ('mmmm' or similar), Excel thinks it's 7th January 1900 and gives you 'January'.

    The easiest way to extract a month for display is to use the TEXT function:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This converts the date to text, so you can't use it in any calculations, but will give you the display you want.

    Hope that helps.

    Edit: Ali beat me to it...
    Last edited by Aardigspook; 08-29-2020 at 03:07 AM. Reason: Acknowledge previous post
    Regards,
    Aardigspook

    I've just moved house, internationally, during COVID (!) so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  4. #4
    Registered User
    Join Date
    09-10-2015
    Location
    Caringbah, NSW, Australia
    MS-Off Ver
    Office 365
    Posts
    27

    Re: I can't get the Month to extract from a date

    Thanks for the speedy response. I'll give it a go. I was thinking of this but thought it may have been an inefficient way of achieving my aim but, as others have indicated, this seems to be the only solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 01-24-2019, 05:30 PM
  2. [SOLVED] Extract Year, Month, Day from date
    By stoicy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-28-2016, 11:48 PM
  3. Extract Year, Month, Day from date
    By stoicy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2016, 01:41 PM
  4. Extract Day from Date returning Month instead of Day
    By Epscan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-06-2013, 01:51 AM
  5. Extract birthday date and month
    By grey_hair in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-02-2011, 12:09 PM
  6. Extract Month from date IE 3/10/2010 = 3
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2010, 12:30 AM
  7. extract the month of a date
    By gireesh in forum Excel General
    Replies: 11
    Last Post: 11-23-2005, 02:10 PM

Tags for this Thread

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