+ Reply to Thread
Results 1 to 8 of 8

Excel 2010 troubles sorting date in Pivot table

Hybrid View

  1. #1
    Registered User
    Join Date
    05-05-2014
    Location
    Ventura
    MS-Off Ver
    Excel 2010
    Posts
    24

    Excel 2010 troubles sorting date in Pivot table

    Hello: I have a datasheet that contains dates and when I right click->format on any cell, it displays that it's date e.g.: 3/14/2001.

    When I go to insert a pivot table that uses this column as part of it's datasource, I then place the date in either the report or column filter and look at it and it sorts the dates like this:

    1/10/2011
    1/10/2012
    1/10/2013
    1/3/2011


    It's just a mess. I want it to show like this:
    1/3/2011
    1/10/2011
    1/10/2012

    I went to the filter off the pivot table and selected the sort asc, but that did absolutely nothing.

    Any help is truly appreciated.

    Thank you,
    Proctor

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,111

    Re: Excel 2010 troubles sorting date in Pivot table

    just as a test in a new cell put
    today() into a cell and then in another cell put cell of the date today() +1
    format as general ?
    do you get a number

    also attach the sheet if you can without issues of privacy
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    05-05-2014
    Location
    Ventura
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Excel 2010 troubles sorting date in Pivot table

    etaf - thank you for your reply.

    I've stripped out enough of the attached sheet so that you can see what's happening.
    I tried your test and it formats as a date that is like this: *3/14/2001; where as mine is just 3/14/2001.
    I did check my regional settings for date and they are in this same format.

    I also wanted to mention, the data is being brought in via vba script when the user clicks a macro button. It goes to my sql 2005 db and gets the data. My boss does not want to see the time along with the date,
    and sql 2005 only has datetime datatype (no short date); so, when I call the sql to bring it in, I use this code:

    sqlstring = "SELECT ShippingId, " & _
    "CONVERT(nvarchar(10),ShipDate, 101) AS ShipDate, " & _
    "Cast(M_ID as INT) AS M_ID FROM Shipping WHERE year between 2011 and 2014 " & _
    " ORDER BY SHIPPINGID, M_ID ASC"

    If I just bring the data in with this sql, when I look at the format, it's general; however, this still has the same sorting issue.
    My code then reformats it so it's date:
    Sheets("ShipData").Range(Cells(1, 14), Cells(1, 15).End(xlDown)).NumberFormat = "m/d/yyyy;@"

    At any rate, the output is shown in the sheet I am attaching.

    Thank you again for your time. I very much appreciate it.

    Proctor
    Attached Files Attached Files

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,111

    Re: Excel 2010 troubles sorting date in Pivot table

    my dates are in UK format - BUT I tried the usual dates being imported , and used TEXT to COLUMNS > Delimited> finish
    and now if i goto general I get a number and the correct type of date number and also when I add 1 it works correctly

    try that on the date column - B
    column D seems to be OK

  5. #5
    Registered User
    Join Date
    05-05-2014
    Location
    Ventura
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Excel 2010 troubles sorting date in Pivot table

    etaf: That seems to work....just, I'm not sure I understand why?

    Sure seems like the dates are very tricky.

    thank you so much for all your help!

    Proctor

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,111

    Re: Excel 2010 troubles sorting date in Pivot table

    often dates an numbers imported via SQL or other databases often look OK but are not , numbers are text - and just clicking on the cell corrects the number - sometimes a value() works , but the Text to Columns often fixes the issues

  7. #7
    Registered User
    Join Date
    05-05-2014
    Location
    Ventura
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Excel 2010 troubles sorting date in Pivot table

    Well it was a great thing to learn! - thanks for showing me this. Thank you also for your time.

    Proctor

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,111

    Re: Excel 2010 troubles sorting date in Pivot table

    your welcome
    if my assistance has helped, and only if you wish to , there is a reputation icon * on the left hand side - you can add to my reputation here

+ 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. [SOLVED] Date Format not Working in Excel 2010 in Pivot Table
    By Lazor78 in forum Excel Charting & Pivots
    Replies: 12
    Last Post: 09-10-2013, 11:28 AM
  2. breaking up of date and time in pivot table excel 2010
    By Stole in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-31-2013, 11:52 AM
  3. 2010 Pivot Table Sorting The Same Order As Data Source
    By Nunzio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-11-2012, 05:47 PM
  4. [SOLVED] An auto-sorting table in MS Excel 2010
    By Arithalion in forum Excel General
    Replies: 2
    Last Post: 05-11-2012, 09:40 AM
  5. Sorting Pivot Table by Pub Date
    By ilundy77 in forum Excel General
    Replies: 2
    Last Post: 06-03-2011, 12:51 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