Google Sheets – How to Sort by Month and Day but Not Year

google sheetsgoogle-sheets-datessortingworksheet-function

I made a Google spreadsheet with a list of birth dates, anniversaries, etc. that I would like to sort by when they occur in the year, not when they first happened.
If you sort by the date normally, it will put the oldest year first.
I'm looking for a way to sort these only by the month and day, so I can get a quick view of what's coming up in what order.

So far, I attempted to make a formula referencing the date column that only shows the month part and the day part, like so:

=month(C2)&"-"&day(C2)

This almost works, except since the values are appearing as text and without a leading 0, it sorts Oct, Nov and Dec right after Jan (since they all start with 1 and are therefore "lower" than 2, 3, etc).
Anyone have a better way to sort this automatically or know a formula function to correct mine?
Simply adding the leading zero to single-digit months would be my way, but I'm open to other options.

Best Answer

Ultimately, you need to do what you already predicted: adding a leading zero. The TEXT function will make that happen like this:

=TEXT(A2, "00")

I've created a formula that takes on the complete column, filter for empty cells, brings together the MONTH and DAY and SORTs the lot.

Formula

=SORT(ARRAYFORMULA(TEXT(MONTH(FILTER(A2:A;A2:A<>""));"00") & " - " 
 & TEXT(DAY(FILTER(A2:A;A2:A<>""));"00"));1;1)

Explained

Here's a break-down description of the formula:

  1. The FILTER function will filter for all rows that have something.
  2. The MONTH and DAY functions will extract the respective values from the date.
  3. The TEXT function will convert the value from point 2 into a pre-formatted STRING.
  4. The ARRAYFORMULA function will apply all the above to the complete column (skipping the header).
  5. The SORT function will sort the result, given by the ARRAYFORMULA.

The SORT function allows for sorting. If you do that via a column sort, the entry of the ARRAYFORMULA is taken into account as well and gets re-positioned, causing mayhem.

Screenshot

enter image description here

Example

See example file I've created: sorting dates as text