Excel date sorting issue

New Contributor

I have a mix date data in the same column; yyyy-mm-dd, and yyyy-mm, and yyyy .

I need to sort it for my research.  yyyy-mm-dd date formats sort, BUT the yyyy-mm, and yyyy do not sort within yyyy-mm-dd list.

I am using the English UK date style, and have tried creating "custom" formats, as well as different excel formats, but I cannot get this to work.

I need to keep year-month(if)-date(if) display .

Any ideas?

6 Replies


dates in Excel are actually integer numbers starting from 01 Jan, 1990 as 1. For example  17 Mar 2021 is actually 44272.  Applying formats like yyyy-mm-dd,  yyyy-mm, or yyyy you only change visual representation of such numbers, it shall not affect sorting.


However, if you have texts as "2021-03-17" and "2021-03" they'll be the text, doesn't matter which format you apply to them, such formatting doesn't affect text value. They are always will be sorted as texts in alphabetical order.


Thus the question is what is your data actually, texts or numbers.



Are the yyyy-mm-dd and yyyy-mm values text? If so, try the following.

Let's say the values are in A2 and down.

In another column, enter the following formula in row 2:




Fill down.

Sort the entire range on the new column. You can hide the new column if you prefer.

thank. But how do I accomplish my goal of being able to sort the dates in order regardless of if they are Year, month, day or year, month or just year?
I understand that there will have to be some type of rule about where does it appear (for example, yyyy in a list of yyyy-mm-dd; beginning or end/)
Would making them text enable me to sort?


If you have texts, not dates, that's how @Hans Vogelaar suggested

Thanks, will give it a try!