+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Treat 6 Digit Number as Date but leave display alone

  1. #1
    Registered User
    Join Date
    06-25-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Treat 6 Digit Number as Date but leave display alone

    I am trying to enter a 6 digit number in a cell, leave the number as entered but treat it as a date. For example:

    311210 would be displayed as 311210 but treated as the date 12/31/2010 (December 31st, 2010). I have tried using Format Cells but it gives crazy results.

  2. #2
    Forum Contributor
    Join Date
    08-11-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    149

    Re: Treat 6 Digit Number as Date but leave display alone

    you're thinking about it backwards.... you want to enter a number and treat it as a date. what you need to do is enter a date and display it as a number (custom format: ddmmyy). Is there any reason why you HAVE to store it in the number format (instead of just displaying it that way)?

  3. #3
    Registered User
    Join Date
    06-25-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Treat 6 Digit Number as Date but leave display alone

    The number is an expiration date printed on outer packaging. The user makes a list of the numbers and then enters them into Excel. I suppose I could add an extra column that would convert the number to a date but would prefer treating the number as a date in the original cell. Asking the user to convert the number to a date defeats the purpose in my opinion.

    What I eventually want to get to is if the Expiration Date is less than 180 days away display the text in red, if 181 to 240 days display the text in blue, otherwise diplay text in green. It would be nicer to do it all in one cell.

  4. #4
    Forum Contributor
    Join Date
    08-11-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    149

    Re: Treat 6 Digit Number as Date but leave display alone

    So if your number was in cell A1, you'd create conditional formatting as follows:
    Condition 1 (format font color green): Formula is =DATE(2000+RIGHT(A1,2),MID(A1,3,2),LEFT(A1,2))-TODAY()>240
    Condition 2 (format font color blue): Formula is =DATE(2000+RIGHT(A1,2),MID(A1,3,2),LEFT(A1,2))-TODAY()>180
    Condition 3 (format font color red): Formula is =DATE(2000+RIGHT(A1,2),MID(A1,3,2),LEFT(A1,2))-TODAY()<=180

  5. #5
    Registered User
    Join Date
    06-25-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Treat 6 Digit Number as Date but leave display alone

    Ah, now I see. I didn't even see the option to select "Use a formula to determine which cells to format" in the Edit Formatting Rule window. I was trying to use "Format only cells that contain" and was just going in circles.

    Thanks.

+ 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