+ Reply to Thread
Results 1 to 14 of 14

Help with a formula to extract dates from SKUs

Hybrid View

  1. #1
    Registered User
    Join Date
    06-13-2016
    Location
    Hampstead North Carolina
    MS-Off Ver
    excel for mac v 15.12.3
    Posts
    4

    Help with a formula to extract dates from SKUs

    I am stuck with the task of trying to pull dates from inventory SKUs for over 150k items. There is no way I could ever do this manually one SKU at a time. I was hoping there was a formula I could apply to all of them that would extract the date from the SKUs. Our SKUs all follow a simple format. An example would be NFL-2016-MAY-14-VG-001. The prefix NFL denotes where the item came from. The 2016-MAY-14 is the date the item was listed. This is the piece of data I need to extract as a date into another column of the spreadsheet, preferably in a normal date format. The VG is the condition of the item, and the 001 is simply a number appended to the end to separate it from the next item in the batch of inventory which would have most likely been NFL-2016-MAY-14-VG-002. The hyphens simply separate out everything.

    Is there any formula that will be able to look at that cell and say, the date needed to be extracted will be 05/14/2016? This is the hardest excel problem I have ever tried to solve, but obviously my excel skills are limited. Any help on this problem would be EXTREMELY appreciated.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,719

    Re: Help with a formula to extract dates from SKUs

    A couple of Assumptions.
    1. SKU is in Cell A1
    2. The prefix (NFL or other) is always 3 characters long
    3. The Date format in the SKU is always 11 characters long (YYYY-MMM-DD)
    4. There are hyphens in the SKU
    In B1 type =(MID(A1,5,11)) and copy it down.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,722

    Re: Help with a formula to extract dates from SKUs

    I cannot tell from your profile if this will work, but starting in Excel 2013 there is a new Flash Fill feature.

    With your SKUs starting in say A1 go to B1 and type in just the part you want to extract from that one sample. Then click Data and Flash Fill. A fly-out icon will prompt for Accept / Undo. This often solves these problems very quickly.
    Dave

  4. #4
    Registered User
    Join Date
    10-14-2015
    Location
    Brisbane
    MS-Off Ver
    2010
    Posts
    12

    Re: Help with a formula to extract dates from SKUs

    Hi:

    One way of doing this, if your string format is going to be always same as you have given in your OP

    Formula: copy to clipboard
    =MID(A1,FIND("-",A1)+1,FIND(CHAR(135),SUBSTITUTE(A1,"-",CHAR(135),3))-2)


    Thanks

  5. #5
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Help with a formula to extract dates from SKUs

    The following code will extract the date assumming the following:

    1. The SKU are in a worksheet named "sheet1"
    2. The SKU is in column "B" and its format is allways XXX-YEAR-MTH-DY-....
    3. The date will be placed in the next cell column "C"


    Sub datefield()
    
    Set sh1 = Sheets("sheet1")
    
    r = 2
    While sh1.Cells(r, 2) <> ""
       st = sh1.Cells(r, 2)
       yr = Mid(st, 5, 4)
       mn = Mid(st, 10, 3)
       dy = Mid(st, 14, 2)
       sh1.Cells(r, 3) = dy & "-" & mn & "-" & yr
        r = r + 1
    Wend
    
    
    End Sub

  6. #6
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: Help with a formula to extract dates from SKUs

    Assumptions:
    1. Text in A1
    2. Hyphens in the text
    3. Only one hyphen between first part and year
    4. One hyphen between the year and month and between the month and day
    5. Month is always Characters and is the following (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC)
    6. Date is always 11 characters.
    Copy and paste in B2-- it converts the text to an actual date that you can display however you want.
    Formula: copy to clipboard
    =DATE(LEFT(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),4),IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="JAN",1,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="FEB",2,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="MAR",3,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="APR",4,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="MAY",5,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="JUN",6,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="JUL",7,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="AUG",8,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="SEP",9,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="OCT",10,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="NOV",11,IF(MID(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1,3)="DEC",12)))))))))))),RIGHT(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),LEN(RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))-FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)),FIND("-",RIGHT(LEFT(A1,FIND("-",A1)+11),LEN(LEFT(A1,FIND("-",A1)+11))-FIND("-",A1)))+1)))
    If your questions has been answered to your satisfaction please don't forget to do the following:

    Add Reputation ... and ... Mark Thread as Solved

    Thanks,

    Ma 10:8b Freely you have received; freely give.

  7. #7
    Registered User
    Join Date
    06-13-2016
    Location
    Hampstead North Carolina
    MS-Off Ver
    excel for mac v 15.12.3
    Posts
    4

    Re: Help with a formula to extract dates from SKUs

    I am completely amazed at this community's willingness to help. I greatly appreciate everyone's input. Mongoose36's formula looks like it will work. The only problem is that we use MLA abbreviation standards for the months, so for example June would appear as JUNE in the SKU. I will probably just run a find and replace on all the 4 character months though and then the formula will most likely work just fine.

    Some of the other suggestions would have worked great if it weren't for 1 or 2 small issues, one of them being that not every prefix is 3 characters.

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,952

    Re: Help with a formula to extract dates from SKUs

    Soln#4 MODIFIED:
    =MID(A1,FIND("-",A1)+1,FIND(CHAR(135),SUBSTITUTE(A1,"-",CHAR(135),4))-FIND("-",A1)-1)
    Ben Van Johnson

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,722

    Re: Help with a formula to extract dates from SKUs

    Another way.

    Formula: copy to clipboard
    =TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"-",REPT(" ",256),4),"-",REPT(" ",256),1),256,256))

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,722

    Re: Help with a formula to extract dates from SKUs

    There is probably a shorter way to do this, and using a helper cell might be a wiser method.

    Is there any formula that will be able to look at that cell and say, the date needed to be extracted will be 05/14/2016?
    This formula does that. It converts the string to numbers. If you are not aware of it dates are numbers which can be formatted as dates. This will return 42504. When formatted for date m/d/yyyy is 5/14/2016.
    Formula: copy to clipboard
    =LOOKUP(25^25,--LEFT(TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(A1,TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"-",REPT(" ",256),3),"-",REPT(" ",256),2),256,256)),MONTH(TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"-",REPT(" ",256),3),"-",REPT(" ",256),2),256,256))&0)),"-",REPT(" ",256),1),256)),ROW($1:$50)))



    Row\Col
    A
    B
    1
    NFL-2016-MAY-14-VG-001
    5/14/2016



    This SUBSTITUTES the month name with the month number. The MONTH(<monthname>&0) part converts the name to a number.
    Last edited by FlameRetired; 06-14-2016 at 06:08 PM.

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,722

    Re: Help with a formula to extract dates from SKUs

    Double posted.

  12. #12
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Help with a formula to extract dates from SKUs

    If all you need is the date without conversion to the real date
    Formula: copy to clipboard
    =MID(A1,SEARCH("-????-???-??-",A1)+1,11)

    v A B
    1 NFL-2016-MAY-14-VG-001 2016-MAY-14
    2 LLLL-DD-2015-JAN-25-VVVVV-25 2015-JAN-25

    If you need it converted to the real date
    Formula: copy to clipboard
    =(RIGHT(MID(A1,SEARCH("-????-???-??-",A1)+1,11),2)&MID(MID(A1,SEARCH("-????-???-??-",A1)+1,11),6,3)&MID(MID(A1,SEARCH("-????-???-??-",A1)+1,11),1,4))+0

    v A B
    1 NFL-2016-MAY-14-VG-001 5/14/2016
    2 LLLL-DD-2015-JAN-25-VVVVV-25 1/25/2015
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  13. #13
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,722

    Re: Help with a formula to extract dates from SKUs

    @ AlKey

    Thanks for another lesson.

    I tried every way I could think of to get the date value. That one never occurred to me.

    Dave

  14. #14
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,722

    Re: Help with a formula to extract dates from SKUs

    rickyanalog,

    Regarding your PM and helper cell try these. They work no matter the length of month text or prefix. If the locations of the "-" characters change this will not work.

    Edited Changed my sample SKUs.


    Row\Col
    A
    B
    C
    D
    1
    SKUs
    Helper
    Dates
    2
    WNFL-2016-MAY-14-VG-001 MAY
    5/14/2016
    In B2 and filled down =TRIM(MID(SUBSTITUTE(SUBSTITUTE(A2,"-",REPT(" ",256),3),"-",REPT(" ",256),2),256,256))
    3
    NL-2016-JUNE-14-VG-002 JUNE
    6/14/2016
    In C2 and filled down =SUBSTITUTE(TRIM(MID(SUBSTITUTE(SUBSTITUTE(A2,"-",REPT(" ",256),4),"-",REPT(" ",256),1),256,256)),B2,MONTH(B2&0))+0
    4
    RSTUVWXYZ-2016-AUGUST-14-VG-003 AUGUST
    8/14/2016
    Format for date.
    5
    99-2016-MAY-7-VG-004 MAY
    5/7/2016
    6
    2-2016-SEP-1-VG-005 SEP
    9/1/2016
    7
    NFL-2016-DECEMBER-14-VG-006 DECEMBER
    12/14/2016
    8
    NFL-2016-JUN-14-VG-007 JUN
    6/14/2016
    Last edited by FlameRetired; 06-14-2016 at 08:27 PM.

+ 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. skus in columm a for each sale, qty. of skus sold, each sale in co
    By JMB in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  2. Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  3. [SOLVED] skus in columm a for each sale, qty. of skus sold, each sale in co
    By confused1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-11-2005, 05:05 PM

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