+ Reply to Thread
Results 1 to 8 of 8

Date problem

  1. #1
    Registered User
    Join Date
    10-18-2006
    Posts
    12

    Date problem

    I'm using this formula to extract a date from a serial number and add 10 years to the result.

    The 2000 dates are all correct, however, all of the 1900 dates are resulting in numbers like:

    19103
    19106
    19108

    What do I need to do to correct this problem?

    Here's the formula:

    =IF(B5="ACME",IF(MID(D5,3,1)*1>=5,19&MID(D5,3,2)+10,20&MID(D5,3,2)+10),"")

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Can you give examples of what may be in D5?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    10-18-2006
    Posts
    12
    Quote Originally Posted by NBVC
    Can you give examples of what may be in D5?
    Yes, It's a number/letter combo. The 3rd and 4th digits will always be the two digit representation of a Year.

    The dates can go back as far as 1950 and as current as yesterday.


    4405E47911 = 2005
    4405E47887 = 2005
    4894E02417 = 1994
    0196E11959 = 1996
    2204E30812 = 2004

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try:

    =IF(B5="ACME",1900+MID(D5,3,2)+IF(MID(D5,3,1)*1>=5,0,100)+10,"")

  5. #5
    Registered User
    Join Date
    10-18-2006
    Posts
    12
    Quote Originally Posted by NBVC
    Try:

    =IF(B5="ACME",1900+MID(D5,3,2)+IF(MID(D5,3,1)*1>=5,0,100)+10,"")
    I tried it and the result was 7/7/05 for D5 with a value of: 4405E47911

    It should have been 2005 with 10 years added: 2015

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Excel is formatting the cell as a date.

    Try to format the cell as General.....

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Your original formula works OK if you just add a few parentheses

    =IF(B5="ACME",IF(MID(D5,3,1)*1>=5,(19&MID(D5,3,2))+10,(20&MID(D5,3,2))+10),"")

    as NBVC says, just format as general

    or, shorter..

    =IF(B5="acme",(20-(MID(D5,3,1)>"4")&MID(D5,3,2))+10,"")

  8. #8
    Registered User
    Join Date
    10-18-2006
    Posts
    12
    Quote Originally Posted by daddylonglegs
    Your original formula works OK if you just add a few parentheses

    =IF(B5="ACME",IF(MID(D5,3,1)*1>=5,(19&MID(D5,3,2))+10,(20&MID(D5,3,2))+10),"")

    as NBVC says, just format as general

    or, shorter..

    =IF(B5="acme",(20-(MID(D5,3,1)>"4")&MID(D5,3,2))+10,"")
    Thanks so much you guys! It works perfectly.

+ 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