+ Reply to Thread
Results 1 to 5 of 5

Date in wrong century

  1. #1
    Registered User
    Join Date
    11-28-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    73

    Date in wrong century

    I need to extract dates from file names. The naming convention is usually a "letter" followed by the year, month, day, time..... I use a formula that is about as simplistic as my skills allow and it works except the dates all come out as 19xx.
    File looks like this Z1501211630.22 the end characters are meaningless.
    My formula looks something like this =DATE(MID(H2,2,2),MID(H2,4,2),MID(H2,6,2)) which works just fine for a short date 1/21/15 but I need a long date.
    I am getting 1915 instead of 2015.

    I'm missing something in my simplicity but what?

  2. #2
    Registered User
    Join Date
    05-13-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Date in wrong century

    https://support.office.com/en-sg/art...b-a32dee59b6e4

    If all years you will encounter are in the 2000 or later, try =DATE("20" & MID(H2,2,2),MID(H2,4,2),MID(H2,6,2)).

    Otherwise, perhaps you could key off of the date the file was created somehow? Or you could establish a rule, like if the 2 digit year is 50 or less, assume it's in the 21st century, but otherwise assume it's the 20th?

    At any rate, you probably should be using more than 2 digits to code for the year in the filename.

  3. #3
    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: Date in wrong century

    Try this one

    =TEXT(MID(H2,4,2)&"/"&MID(H2,6,2)&"/"&MID(H2,2,2),"m/d/yyyy")

    to convert to real date:

    =TEXT(MID(H2,4,2)&"/"&MID(H2,6,2)&"/"&MID(H2,2,2),"m/d/yyyy")+0
    Last edited by AlKey; 01-21-2015 at 09:46 PM.
    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

  4. #4
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,373

    Re: Date in wrong century

    =date(mid(h2,2,2)+2000,mid(h2,4,2),mid(h2,6,2))

  5. #5
    Registered User
    Join Date
    11-28-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: Date in wrong century

    Quote Originally Posted by eboomer View Post
    https://support.office.com/en-sg/art...b-a32dee59b6e4

    If all years you will encounter are in the 2000 or later, try =DATE("20" & MID(H2,2,2),MID(H2,4,2),MID(H2,6,2)).

    Otherwise, perhaps you could key off of the date the file was created somehow? Or you could establish a rule, like if the 2 digit year is 50 or less, assume it's in the 21st century, but otherwise assume it's the 20th?

    At any rate, you probably should be using more than 2 digits to code for the year in the filename.
    That would be great if it was my file but it is computer generated in several reports that I download.

    I'll give your formula a shot ........thanks

+ 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. On An Import To Excel A Two Digit Date is the wrong century.
    By scyllanbay in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-03-2012, 05:45 PM
  2. 19th century date
    By rohnds in forum Excel General
    Replies: 8
    Last Post: 01-16-2012, 02:51 AM
  3. converting date problem and eliminate century
    By jg53 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-14-2007, 01:37 PM
  4. Replies: 3
    Last Post: 11-07-2005, 10:50 PM
  5. [SOLVED] How can I determine the century of a date in Excel?
    By Robin in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-27-2005, 02: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