Questions tagged [ordinals]

Ordinal numbers, representing position in an order.

Ordinal numbers are words representing position or rank in a sequential order. Examples: "First", "Second", "Third"…

72 questions
231
votes
23 answers

Is there an easy way to create ordinals in C#?

Is there an easy way in C# to create Ordinals for a number? For example: 1 returns 1st 2 returns 2nd 3 returns 3rd ...etc Can this be done through String.Format() or are there any functions available to do this?
GateKiller
  • 74,180
  • 73
  • 171
  • 204
87
votes
16 answers

Ordinal numbers replacement

I am currently looking for the way to replace words like first, second, third,...with appropriate ordinal number representation (1st, 2nd, 3rd). I have been googling for the last week and I didn't find any useful standard tool or any function from…
skornos
  • 3,121
  • 1
  • 26
  • 30
73
votes
11 answers

Is there an easy way in .NET to get "st", "nd", "rd" and "th" endings for numbers?

I am wondering if there is a method or format string I'm missing in .NET to convert the following: 1 to 1st 2 to 2nd 3 to 3rd 4 to 4th 11 to 11th 101 to 101st 111 to 111th This link has a bad example of the basic principle involved…
Matt Mitchell
  • 40,943
  • 35
  • 118
  • 185
38
votes
10 answers

Is it possible to select sql server data using column ordinal position

Is it possible to select column data using the ordinal_position for a table column? I know using ordinal positions is a bad practice but for a one-off data import process I need to be able to use the ordinal position to get the column data. So for…
rams
  • 6,381
  • 8
  • 46
  • 65
35
votes
6 answers

Benefits Of Using SQL Ordinal Position Notation?

Background Information Ordinal position notation, AKA ordinals, is column shorthand based on the column order in the list of columns in the SELECT clause, instead of either the column name or column alias. Commonly supported in the ORDER BY clause,…
OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
18
votes
2 answers

How to replace 1 with first, 2 with second,3 with third etc

Is there any inbuilt js/jquery function that converts 1 to first, 2 to second, 3 to third... etc.? ex: Num2Str(1); //returns first; Num2str(2); //returns second; I dont want to write a function for 100 numbers. Please help.
EvilDevil
  • 680
  • 1
  • 7
  • 18
16
votes
1 answer

How can I call a exported function using ordinal number

If a dll exports some functions and the functions have only ordinal numbers, how can I call the functions? Give me a short example please.
Benjamin
  • 10,085
  • 19
  • 80
  • 130
12
votes
8 answers

Javascript: Ordinal suffix for numbers with specific CSS class

I am trying to display numbers within a particular table with ordinal suffixes. The table always shows three numbers which come from an XML file. The numbers show ranks, so for example they may be 6th, 120th, 131st. The output is a table that would…
rf2012
  • 233
  • 2
  • 7
  • 13
10
votes
3 answers

is there an ordinal to cardinal function in ruby or rails?

I'm trying to find a better way in expressing my cucumbers so I am looking for an ordinal to cardinal function that converts this: When I fill up the first passenger field Then I should see the passenger list update with the first passenger…
corroded
  • 21,406
  • 19
  • 83
  • 132
9
votes
7 answers

PHP: increment counter function using words (i.e. First, Second, Third, etc.. )

I've been trying to find a function which increments a counter using words. I know its possible using numbers with suffixes (i.e. 1st, 2nd, 3rd and so on). Here is a snippet of the code i've got: function addOrdinalNumberSuffix($num) { if…
VicePrez
  • 540
  • 1
  • 8
  • 17
9
votes
5 answers

How to convert Cardinal numbers into Ordinal ones

Is there an easy way to convert the number 1, 2, 3, ... to "1st", "2nd", "3rd", ..., and in such a way that I can give the function a language and have it return me the correct form for the language I'm targeting? Either standard C++ (stl or boost…
Roel
  • 19,338
  • 6
  • 61
  • 90
7
votes
1 answer

Get the ordinal position while creating selected Item in a LINQ expression

How can I get the ordinal position while creating selected Items in a LINQ expression? For example: var alphaordinals = new string[] { "A", "B", "C", "D", "E" }; // etc. var q = from car in datacontext.Cars select new InventoryItem …
Ash Machine
  • 9,601
  • 11
  • 45
  • 52
7
votes
2 answers

Is there a simple method of converting an ordinal numeric string to its matching numeric value?

Does anyone know of a method to convert words like "first", "tenth" and "one hundredth" to their numeric equivalent? Samples: "first" -> 1, "second" -> 2, "tenth" -> 10, "hundredth" -> 100 Any algorithm will suffice but I'm writing this in…
soutarm
  • 831
  • 1
  • 8
  • 14
6
votes
1 answer

localize ordinal numbers

for ($rank=0; $rank<100; $rank++) { printf("Your rank: %d%s", $rank, $suffix); } Does there exist a gettext function to localize $suffix to the current language and return, for example: Your rank: 0th Your rank: 1st Your rank:…
abernier
  • 27,030
  • 20
  • 83
  • 114
5
votes
2 answers

Formatting a DateTime value Day value

Is there a simple method of displaying the day portion of a date in the format 1st, 2nd, 3rd,…? I suspect that there is no method of doing this through custom datetime formatstrings (I will be very happy to be wrong), so has anyone implemented a way…
detaylor
  • 7,112
  • 1
  • 27
  • 46
1
2 3 4 5