|
|
Title | Find ordinal extensions (as in 1st, 2nd, 143rd, etc.) |
Keywords | ordinal extension, 1st, 2nd, 3rd |
Categories | Algorithms, Strings |
|
|
By Peter Chamberlin.
|
|
' Extend Date Number to Include Text Suffix
Public Function DateExtension(ByVal DateNum) As String
Dim DateRemainder As Integer
' Default to Most Common Extension
DateExtension = "th"
' Handle ?11th through ?13th
DateRemainder = DateNum Mod 100
' If Not An Exception
If DateRemainder < 11 Or DateRemainder > 13 Then
' Get Right Digit
Select Case DateNum Mod 10
' Update Appropriate Extension
Case 1: DateExtension = "st"
Case 2: DateExtension = "nd"
Case 3: DateExtension = "rd"
End Select
End If
' Add Extension to Original Number
DateExtension = DateNum & DateExtension
End Function
|
|
|
|
|
|