Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need day of month function (1="first", 2="second", 16="

Status
Not open for further replies.

jschodde

Technical User
Jan 28, 2001
42
US
Hi All,
I need some ideas on how to convert the day of month to words like this:

Day of Month Word
------------ --------------
1 first
2 second
...
16 sixteenth
30 thirtieth
---------------------------------

Should I consider a 31-element array like this?:
["first","second","third"...]

Then index the array with the day of the month?

What do you think?

-Jeff
 
Well,
For now I've solved my own problem. If anyone has a better (i.e. more efficient) way of doing this, I would be happy to hear it.

stringvar array numbers:=["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelfth","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth","twentieth","twenty-first","twenty-second","twenty-third","twenty-fourth","twenty-fifth","twenty-sixth","twenty-seventh","twenty-eighth","twenty-ninth","thirtieth","thirty-first"];
numbers[Day(today())]

-Jeff
 
If you want cardinal numbers, you can use ToWords(11,0), which returns "eleven".
There is no function for ordinal numbers though - making an array (like you have done) is probably the simplest way to do this. Malcolm
 
Cool! I did not think about the ToWords() function. I'll have to remember that. Also, thanks for the terminology: "ordinal" and "cardinal". I could not think of the right words to explain it.

-Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top