+ Reply to Thread
Results 1 to 6 of 6

Excel formatting some dates, not others

Hybrid View

  1. #1
    Registered User
    Join Date
    09-13-2011
    Location
    Los Angeles, California
    MS-Off Ver
    Excel 2003
    Posts
    56

    Excel formatting some dates, not others

    I started out with an excel sheet that I coped a bunch of dates into one column. The problem was these dates copied in with not just the dates, but ahead of every date, the day of the week the date was, in abbreviated fashion.

    For example, FRI OCT 21, 2011, is how one date would read. Every date was like this, except with THU or TUE or SAT ahead of the dates. So when I tried to sort the dates, they wouldn't sort by date, they would sort by day of the week. This was a problem for me.

    To get around this problem, I thought I would use the replace function. I put in "FRI" and replaced it with nothing (basically deleting FRI), then SAT, then SUN, and I did this for every day of the week.

    Before i knew it, not only were the days of the week gone, but excel had automatically formatted my dates, for some reason. Instead of OCT 21, 2011 excel changed it to 21-Oct-11.

    Even though I dont understand the mechanism behind this change, it worked fine. I could now sort the dates. Except, at the very end, I noticed about 15 of the dates were unchanged, still in the "OCT 21, 2011" format. If the column had been entirely that way, or entirely the other way, either would have been fine, I believe. But because there are two different formats, now I still cant sort the dates in order.

    How do I fix this? Why did some of them become unaltered? I even tried highlighting them, and manually going to format, dates, and selecting the 21-Oct-11 way, and it did nothing!

    Here is a dummy sheet so you can see.
    Attached Files Attached Files

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Excel formatting some dates, not others

    select only the dates at end in DEC 16, 2011 format
    then data/text to columns/next/next choose date and select mdy click finish then re sort
    ahh that has a problem with jan 6
    try in b2
    =IF(ISNUMBER(A2),A2,DATE(RIGHT(TRIM(A2),4),LOOKUP(LEFT(TRIM(A2),3),{"apr","aug","dec","feb","jan","jul","jun","mar","may","nov","oct","sep"},{4,8,12,2,1,7,6,3,5,11,10,9}),TRIM(MID(A2,FIND(",",A2)-2,2)))) dragged down
    but there must be a better way
    Last edited by martindwilson; 09-18-2011 at 02:11 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    09-18-2011
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    2

    Re: Excel formatting some dates, not others

    Definitely there is a better way. Try this =IF(T(A2)="",A2,DATEVALUE(A2))
    drag the formula and then convert to values. Then give it date format of your choice. or copy and paste special date format from a-column. Now it will arrange properly.
    The reason it is not arranging is because excel is understanding some as dates and some as simple text. The above formula first checks if its text , if true it leaves it as it is and if its not it converts to date value.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Excel formatting some dates, not others

    =DATEVALUE(A70) does not work did you test it? the function requires text in the format 12/21/2000

  5. #5
    Registered User
    Join Date
    09-18-2011
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    2

    Re: Excel formatting some dates, not others

    Quote Originally Posted by martindwilson View Post
    =DATEVALUE(A70) does not work did you test it? the function requires text in the format 12/21/2000
    I tested it again and its working. Meanwhile I thought of an easier way:

    If objective is to arrange the dates then you can make an adjoining B column and name header as Value. In second cell use function =value(A2) and arrange this Value column and the original column would arrange automatically.

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Excel formatting some dates, not others

    it must be a regional settings thing then , definitely doesn't work with my uk dd/mm/yyyy system settings.
    yep i just changed my system region to us english and it worked.
    so since Excelatexcel is in LA thats the way to go
    Attached Images Attached Images
    Last edited by martindwilson; 09-18-2011 at 08:44 PM.

+ 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