+ Reply to Thread
Results 1 to 13 of 13

Thread: Four Digits into a Date

  1. #1
    Registered User
    Join Date
    01-19-2009
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Four Digits into a Date

    I get date information in the format mmyy (eg. 0311 is March, 2011). Is there any way to either make the information yymm or change it into some other Excel recognizable format that can be displayed (eg. Mar-2011, etc.)?

    I'm trying to conditionally format the cells so that certain dates receive different background colors, depending on how far in the future they are. In the current format, I can't seem to make Excel realize which range I want to color.

    Thanks!

  2. #2
    Registered User
    Join Date
    01-18-2009
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Smile Format Dates

    hi,

    you can format your cells to show them in the order that you want.
    Right click then format cells
    On custom, enter yymm as you suggested

    hope that helps

  3. #3
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,564
    Hi,

    How about
    =DATE(RIGHT(A1,2),LEFT(A1,2),1)
    formatted as mmm-yyyy

    HTH

  4. #4
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64
    if your dates start in cell A2, you can put this in B2 and fill down:

    =DATE(VALUE(20&RIGHT(A2,2)),VALUE(LEFT(A2,2)),1)

    ...however, this assumes that you don't have any years before 2000 and no years after 2099. After doing this, you can copy the new column, right click, Paste Special --> values --> OK to just keep the dates and not the formulas. Format in one of the Month-Year formats.

  5. #5
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,055
    I believe Richard's suggestion will give Mar-1911. You could tweak it as follows to give Mar-2011

    =DATE(RIGHT(A1,2)+100,LEFT(A1,2),1)

  6. #6
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,564
    Hi ddll

    Thanks for the correction - I hadn't spotted that. Which has actually identified what looks like a bug in Excel for Mac 2004.

    There's a parameter setting whereby 2 digit year numbers less than the parameter digits are treated (or should be treated) as 21st century, whereas 2 digit numbers greater than the param are 20th C. e.g. with a parameter of 30, the system implies that =Date(11,1,1) will display 1st Jan 2011, whereas =date(31,1,1) will display 1st Jan 1931.

    Is there a similar setting in Excel for Windows?

    Rgds

  7. #7
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,770
    Control Panel, Regional and Language Options, Regional Options, Customize, Date
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,055
    Quote Originally Posted by Richard Buttrey View Post
    There's a parameter setting whereby 2 digit year numbers less than the parameter digits are treated (or should be treated) as 21st century, whereas 2 digit numbers greater than the param are 20th C. e.g. with a parameter of 30, the system implies that =Date(11,1,1) will display 1st Jan 2011, whereas =date(31,1,1) will display 1st Jan 1931.
    It doesn't work that way for DATE function, Richard. If you use DATE(11,1,1) then you'll always get 1911. If the year is a number less than 1900 then it's always assumed that the year is that number + 1900 so both of these give the same date

    =DATE(2011,1,1)

    =DATE(111,1,1)

    The parameter to which you refer only applies to dates typed like 1/1/11, which would be interpreted as 2011, or 1/1/31 which would be interpreted as 1931

  9. #9
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,564
    Excellent ddll. Thanks for that clarification. You live and learn as they say....

    Rgds

  10. #10
    Registered User
    Join Date
    01-19-2009
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    3
    OK, you guys are awesome.

    While I tried the first suggestion (Excel seems to turn the number into a date based on the number of days past 01 Jan 1900, so all the dates were pretty early), I'm going to try the other suggestions.

    Thanks so much for all the help.

    Edit:
    OK, I have tried most of the suggestions and here are some of the results:
    0311 (should be Mar-2011): Jul-2013
    1210 (should be Dec-2010): Dec-2010 (Huzzah!)
    0611 (should be Jun-2011): Jan-2016
    0910 (should be Aug-2010): Jul-2017

    So, it's a mixed bag, but each of the following gave the same results:
    =DATE(RIGHT(A1,2),LEFT(A1,2),1)
    =DATE(VALUE(20&RIGHT(A2,2)),VALUE(LEFT(A2,2)),1)
    =DATE(RIGHT(A1,2)+100,LEFT(A1,2),1)
    If I haven't mentioned it, I'm using Excel 2007, though that shouldn't matter much here.

    So, if anyone has any more insight, I'd be very grateful. In fact, if I could just swap the first two digits and the last two digits, I feel I could achieve my goal.

    More Edit:
    OK, I've also tried:
    =VALUE(RIGHT(L4,2)&LEFT(L4,2))

    but this doesn't do it, either. Because I have added a "0" in front of the first nine months, the formula doesn't really work (0311 turns into 1131 for some reason). So, there are some solutions for the first nine months and some for the last three, but I'm having trouble finding that universal answer.

    If I can get the numbers to read:
    311 => 1103
    1210 => 1012
    611 => 1106
    911 => 1009
    I'd be in like Flynn.
    Last edited by dogfood411; 01-20-2009 at 11:08 AM.

  11. #11
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,055
    Try using this formula which will work even if the leading zero is the result of formatting

    =DATE(RIGHT(A1,2)+100,LEFT(TEXT(A1,"0000"),2),1)

    custom format result cell as mmm-yyyy

  12. #12
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    6,564
    Quote Originally Posted by dogfood411 View Post
    OK, you guys are awesome.

    OK, I have tried most of the suggestions and here are some of the results:
    0311 (should be Mar-2011): Jul-2013
    1210 (should be Dec-2010): Dec-2010 (Huzzah!)
    0611 (should be Jun-2011): Jan-2016
    0910 (should be Aug-2010): Jul-2017

    Hi,
    With the above 0311,1210 etc in A1:A4 then the formula below, which I think has been suggested before, produces the results you expect. Not quite sure why you're getting July 2013 for instance
    =DATE(RIGHT(A1,2)+100,LEFT(A1,2),1)
    Rgds

  13. #13
    Registered User
    Join Date
    01-19-2009
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    3
    Fantastic!

    I used DDL's suggestion and the angels started singing.

    Thanks, all!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0