Why doesn't my date sort work?

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
705
Office Version
  1. 365
Platform
  1. Windows
I should know this. I have a column (AA) with date/time in this format: 7/1/2008 12:23:01 PM
I have another column where I want the month and year so I do =(text(aa2,"mmm-dd") and for this example it shows up as Jul-08.

But when I try sort sort the column or do a pivot table it all sorts in alphabetical order. I checked the cell format for the column and it looks ok - I selected MAR-01.

What gives?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Presumably its because you've used the TEXT function.

Instead of that you could make the cell just equal to AA2 and then get it to show the month and year by changing the formatting to "mmm-yy"

(Also, you've used "dd" in your example instead of "yy")
 
Upvote 0
typo in my original. I do use mmm-yy.

If I jsut formatthe original cell to mmm-yy the pivot table recognizes the time do every record for January shows up as a separate row even though they all show up as Jan-08
 
Upvote 0
I'm not too familiar with pivot tables, but try this...

=DATE(YEAR(AA2),MONTH(AA2),1)

This will give you the first day of the month. You can then apply formatting of "mmm-yy" to show what you want, but the underlying dates for Jan 09, say, will all be the same. Hopefully this will solve the pivot table issue.
 
Upvote 0
Hi SandsB,

Try this:

After you extracted the date using text formula, go to Data -> Sort. Select the range you want to sort along with the date. Then, select "sort anything that looks like a number, as a number".
[By default, the option selected was "sort numbers and numbers stored as text separately"]

This is working in my PC.

Thanks,
Raghav.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top