Home > Software design >  Sort sheet according to birthday date without considering the year of a date
Sort sheet according to birthday date without considering the year of a date

Time:04-10

I am trying to sort sheet according to birthday date, the closest birthday should go in first row, and the last go to the end and so on, to do this it should only consider the day and month without taking into account the year for the sorting, all this by using the query function since the data is being queried from another sheet.

I have tried using the following

=SORT(QUERY('Sheet1'!A2:Q, "SELECT * "),6,FALSE)

but it is not working, i have also tried formatting the data to show only day and month via google sheets custom date and time, and still only hides the year but for sorting still considers the year, and if I aply a filter for sorting it will not work since it is a query function. Any suggestion?

enter image description here


update:

=ARRAYFORMULA(ARRAY_CONSTRAIN({
 QUERY(SORT({Sheet1!A2:Q27, TO_DATE(TEXT(Sheet1!F2:F27, "2222-mm-dd")*1)}, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null and Col18 >= date '"&TEXT(DATE(2222, MONTH(TODAY()), DAY(TODAY())), "e-m-d")&"'", 0);
 QUERY(SORT({Sheet1!A2:Q27, TO_DATE(TEXT(Sheet1!F2:F27, "2222-mm-dd")*1)}, TEXT(Sheet1!F2:F27, "mmdd")*1, 1), 
 "where Col6 is not null and Col18 < date '"&TEXT(DATE(2222, MONTH(TODAY()), DAY(TODAY())), "e-m-d")&"'", 0)}, 9^9, 17))

enter image description here

  • Related