Brian Dunning's FileMaker Custom Functions

Ordinal ( number )

Converts an integer into an ordinal number (1st, 2nd, 3rd).

  Average rating: 3.8 (45 votes) Log in to vote

Vaughan Bromfield   Vaughan Bromfield - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
Ordinal ( 6 )
  Sample output:
6th

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Based on a discussion held on FM Forums.
Contributions by Bob Weaver, LaRetta, and Vaughan Bromfield.

This function returns the number appended with the ordinal text.

Let(

[
d = Int( GetAsNumber( number ) ) ;
n = Mod ( Abs( d ) ; 100 )
] ;

d & Choose ( Min( 4 ; Mod( n ; 10 ) ) * ( ( n < 11 ) or ( n > 13 ) ) ; "th" ; "st" ; "nd" ; "rd" ; "th" )

)

 

Comments

Simon Jenkins   Simon Jenkins, Llanwrda
Mar 20, 2018
Guys -

Hi, brilliant script - thank you.

However, when I come to export an excel sheet, the export cuts off the ordinal, ie :

1st just appears as 1 in excel, 28th as 28 etc.

Am I missing something to allow the ordinal part to be exported to excel?

Many thanks
 
Vaughan Bromfield   Vaughan Bromfield
Mar 21, 2018
That's Excel modifying the data, nothing to do with FileMaker.

To confirm, open the exported data (csv or whatever) in a text editor (NOT Excel).
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: