Applying date ordinal to an array of dates.

HighAndWilder

Well-known Member
Joined
Nov 4, 2006
Messages
712
Office Version
  1. 365
Platform
  1. Windows
I would like to display dates in an array as an ordinal number.

I have an array of dates which could be thousands in numbe :
01/01/2024 02/01/2024 03/01/2024 04/01/2024 05/01/2024

The array could hold the actual day instead of the date.

This will return the ordinal suffix where * represents the day number.
IF(OR(VALUE(RIGHT(DAY(*),2))={11,12,13}),"th",IF(OR(VALUE(RIGHT(DAY(*)))={1,2,3}),CHOOSE(RIGHT(DAY(*)),"st","nd","rd"),"th"))

How do I implement this for each element of the dates / days array?

I thought about having a constant as below and create an array using TEXTSPLIT
1st,2nd,3rd,4th,5th,6th,7th,8th,9th,10th,11th,12th,13th,14th,15th,16th,17th,18th,19th,20th,21st,22nd,23rd,24th,25th,26th,27th,28th,29th,30th,31st

and then using INDEX to return the correct element represented by X but I still don't know how to merge the two arrays.
INDEX(TEXTSPLIT("1st,2nd,3rd,4th,5th,6th,7th,8th,9th,10th,11th,12th,13th,14th,15th,16th,17th,18th,19th,20th,21st,22nd,23rd,24th,25th,26th,27th,28th,29th,30th,31st",","),X)

Also is there a way to call a UDF passing an array and returning a new / edited array?

Thanks
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
How about:

Book1
AB
110/1/20241st
210/2/20242nd
310/3/20243rd
410/4/20244th
510/5/20245th
610/6/20246th
710/7/20247th
810/8/20248th
910/9/20249th
1010/10/202410th
1110/11/202411th
1210/12/202412th
1310/13/202413th
1410/14/202414th
1510/15/202415th
1610/16/202416th
1710/17/202417th
1810/18/202418th
1910/19/202419th
2010/20/202420th
2110/21/202421st
2210/22/202422nd
2310/23/202423rd
2410/24/202424th
2510/25/202425th
2610/26/202426th
2710/27/202427th
2810/28/202428th
2910/29/202429th
3010/30/202430th
3110/31/202431st
Sheet2
Cell Formulas
RangeFormula
A1:A31A1=SEQUENCE(31,,DATE(2024,10,1))
B1:B31B1=LET(d,DAY(A1#),d&XLOOKUP(d,{1,2,3,21,22,23,31},{"st","nd","rd","st","nd","rd","st"},"th",0))
Dynamic array formulas.


And yes, you can have a UDF take and output an array.
 
Last edited:
Upvote 0
Solution
How about:

Book1
AB
110/1/20241st
210/2/20242nd
310/3/20243rd
410/4/20244th
510/5/20245th
610/6/20246th
710/7/20247th
810/8/20248th
910/9/20249th
1010/10/202410th
1110/11/202411th
1210/12/202412th
1310/13/202413th
1410/14/202414th
1510/15/202415th
1610/16/202416th
1710/17/202417th
1810/18/202418th
1910/19/202419th
2010/20/202420th
2110/21/202421st
2210/22/202422nd
2310/23/202423rd
2410/24/202424th
2510/25/202425th
2610/26/202426th
2710/27/202427th
2810/28/202428th
2910/29/202429th
3010/30/202430th
3110/31/202431st
Sheet2
Cell Formulas
RangeFormula
A1:A31A1=SEQUENCE(31,,DATE(2024,10,1))
B1:B31B1=LET(d,DAY(A1#),d&XLOOKUP(d,{1,2,3,21,22,23,31},{"st","nd","rd","st","nd","rd","st"},"th",0))
Dynamic array formulas.


And yes, you can have a UDF take and output an array.
Thanks Eric.

I didn't realise that one could use XLOOKUP using two arrays like that but it makes sense.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,109
Members
453,021
Latest member
Justyna P

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