+ Reply to Thread
Results 1 to 18 of 18

Extract date from string

  1. #1
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Extract date from string

    I have a long list of file names in an excel spreadsheet which come in all shapes and sizes, the only consistent is that in the file is a month/year in the format of MMMM YYYY (eg December 2019) - where this exists in the file name varies.

    How can I extract this date from the text? I will ultimately want the last date in the month so will use EOMonth function to get the day element of the date.

    Thanks for your help

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Extract date from string

    A sample like the yellow banner instructions will really help. As to do it we need to make sure to exclude other items. There may be other characters in the strings that we can search by

  3. #3
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Re: Extract date from string

    Apologies, below is some samples from the list of filenames in column A but really there is no consistency other than it is full month name followed by four digit year;:


    HCRIF Fees - September 2018 - 2.xlsx
    HCRIF Fees - September 2018.xlsx
    CRIF Fees - September 2019.xlsx
    HODI Fees - April 2018.xlsx
    HDOI Fees - April 2019 adjusted.xlsx
    MDQ April 2019 Fees.xlsx
    Fees for May 2019 Std Files exc.Irish.xlsx
    March 2020 - Global -Ireland Fees.xlsx

    third time lucky then
    Attached Files Attached Files
    Last edited by Sandtree; 06-02-2020 at 06:48 AM.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    You were asked to provide a workbook. There are instructions at the top of the page explaining how to attach your sample workbook.

    Administrative Note:

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below or the REPLY button instead of REPLY WITH QUOTE.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Re: Extract date from string

    No worries Ali... past experience of other forum software means that users may only get a notification if they are replied to via a quote and otherwise only get notified if they chose to subscribe to the thread... clearly you've set your system up differently (or dont want the convenience of user notification).

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    No, that's not true - if someone subscribes to a thread (either by default or by choice - see your forum user settings), they will get notified of any response to it. Quoting someone makes no difference at all.

    I would not ask you not to do something that might then impair another user's experience. I am a moderator - it is not my forum, nor is it my system, and the forum has been like this forever.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    Regarding your query: the problem you are going to have, obviously, is the lack of unity between these entries. If all months were preceded by a dash and a space, it would be easy. You are going to need something that recognises the names of months - do all of the entries have the month name and year in the format of the sample data?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    OK - it's a bit of a monster!

    =EOMONTH(DATE(MID(A2,FIND(IFERROR(LOOKUP(1000,SEARCH($J$2:$J$13,A2),$J$2:$J$13),""),A2)+LEN(IFERROR(LOOKUP(1000,SEARCH($J$2:$J$13,A2),$J$2:$J$13),""))+1,4),MONTH(DATEVALUE(IFERROR(LOOKUP(1000,SEARCH($J$2:$J$13,A2),$J$2:$J$13),"")&" 1")),1),0)

    LOOKUP range:

    Excel 2016 (Windows) 32 bit
    J
    1
    2
    January
    3
    February
    4
    March
    5
    April
    6
    May
    7
    June
    8
    July
    9
    August
    10
    September
    11
    October
    12
    November
    13
    December
    Sheet: Sheet1
    Last edited by AliGW; 06-02-2020 at 07:22 AM.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    Here's your workbook with my suggestion implemented.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Re: Extract date from string

    In terms of your first point, clearly different forums use different software that function in slightly different ways... the forums I moderate on will notify someone to a "reply" if they are quoted irrespective of if they have subscribed to the thread (by default or active choice), similarly "at" username also notifies them. Clearly this isnt how this forum is set up so point noted.

    On your second post... having looked through the cases I can see a handful where they have put a date in DD-MM-YY format but I will deal with them by exception -v- the thousands which follow the format of MMMM YYYY. Unfortunately this is only one of my problems in trying to consolidate the data which has been done over many years, by many people without strict controls... the rest so far I've managed to deal with via VBA, SQL or excel.

    On the penultimate and final post... many thanks - will now test to ensure its working (not that I am doubting it will)

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    You may want to see what PowerQuery can do to help - it's great for normalising data.

    I, too, moderate on multiple forums.

  12. #12
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Re: Extract date from string

    I may look at it for future activities... unfortunately this is on a work's machine and getting permission to install anything is a major fight and a couple of grand of testing unless its on a very short list of approved applications and plug ins. For reasons unknown, and I am not telling anyone, the machine had SSMS and SQL Express preinstalled and so I am at least thankful of not having to try and put all this data into an Access database to query!

    Thanks again for the help.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    So which version are you using on the works machine? It's a free Microsoft add-in, and it's bundled into Excel 2016 and above.

  14. #14
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Re: Extract date from string

    I was just upgraded to 2013... the price of the software itself is generally irrelevant, its the cost for them testing that it doesnt introduce vulnerabilities, plays nicely with their bespoke systems (which is why until recently I was on 2010 and then only got 2013 after I pointed out I use their bespoke system on read only for my convenience and could live without it if the upgrade broke it) and then its packaged for delivery via centralised distribution.

    There are times when it can be morally testing... at a former clients I needed to get the hashcodes for files for inclusion in a contract. Speaking to IT for the counterparty's preferred solution IT said its £6,000 and 6-9 months wait for this opensource/freeware application or if I could wait 2 months an alternative opensource solution was already going through the process (or actually the preferred solution didnt require installation so you could just download it and run it if you wanted without telling anyone). On the flip-side, if it turns out the software uploads all the data you run through it to some random person's server you may not want to be the one to explain why you uploaded 300,000 customers medical, bank and address details

    All very frustrating but you can somewhat understand the corporate governance that demands it.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    So even through it's a proprietary Microsoft add-in that will be bundled with the next version of Office they upgrade to, they won't install it? Bizarre. Do they realise it's not third-party???

  16. #16
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Re: Extract date from string

    Yes, Microsoft isn't blindly trusted any more than anyone else. Even basic patches and updates to existing operating systems and Office etc all have to go through all this governance, regression testing and packaging (though generally much quicker if its for a major security vulnerability).

    But again, imagine trying to explain to your 10 million customers why they cannot withdraw money from their bank or pay for their groceries using their card because IT blindly put in a service pack into all the banks windows desktops and servers overnight and it broke compatibility with some archaic hardware or software and rolling back is going to take a week. It creates a culture where anything is only done if it can be really justified and has been fully tested... hence most our people are still using Office 2010 - no one has come up with the business case to justify the project for Microsoft 365 yet. The fear creates governance, the governance creates technical papers/testing etc which in turn creates jobs (and generally well paid).

    Worst of all is trying to do something collaboratively with another large corporate entity.. had a previous standoff where our IT Security bods said our file exchange mechanism had to be used and the other party will have to install appropriate FTP client and their IT Security stated that they do not consider FTP clients to be acceptable and we had to use their web interface solution but due to our firewall/proxy settings it limited it to files up to 10mb (which wasnt going to work).

    I think it is one of the reasons why business users like SAAS options because once you've gone through the process of getting it approved for use a lot of the maintenance and small changes etc they can avoid the same level of governance than if it was a locally installed solution so can be more agile. Unfortunately though I have seen call centres having to use big maps with pins in them to arrange emergency repairs for customers when as SAAS solution fell due to a poorly applied config change resulting in long call waiting, wrong emergency engineers (customer said stratford so the advisor thought east london but was actually in stratford upon avon), lost data, manual rekeying etc.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: Extract date from string

    I wasn't suggesting they shouldn't test it - honestly, I'm not quite that stupid - just saying that it would be one that would be worth the time investing in checking it out. I could not live without PQ - I use it every day at work.

    Anyway, I am keeping you from testing my solution ...

  18. #18
    Registered User
    Join Date
    06-02-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    51

    Re: Extract date from string

    My Excel is still running a VBA script so cannot use it... damned actuaries building ridiculously complex models.

    Its the business case justification and comparison to other things in the backlog... £6k of IT time to provide a piece of software to one user (especially when that user is a temp) -v- using those IT guys to do some system change that increases revenue by a predicted 5%... I will look into it as it may be at a future client its already approved and so its just a simple job of going through the basic request process.

    As I say, the barrier to getting new software approved simply stops people from requesting it in the first place.

+ 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. Extract date from text string
    By Musciak in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-09-2019, 08:01 AM
  2. [SOLVED] How can I extract a date from a string?
    By Tooley in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-06-2017, 11:21 AM
  3. VBA to extract date from string
    By saravanan1981 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-09-2016, 11:33 AM
  4. Extract date and time from a string
    By pickslides in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-19-2014, 09:07 PM
  5. [SOLVED] Extract a date from a string
    By DavidNO in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 12-19-2013, 05:55 PM
  6. Extract date from string
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-01-2011, 08:39 AM
  7. extract date from string
    By kdp145 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-03-2006, 10:54 AM

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