adding st, nd, rd, or th extensions to numbers.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have dates stored in a table field. I can extract just the day fine. For
example, if I have 2/5/04 stored. I can extract the day 5.

Is there a way I can extract and then print on a report the proper extension
to the number that is 1st, 2nd, 3rd, 4th, 5th, etc?

I'm suing Access 2000.

Thank you in advance for your help.
 
Principal said:
I have dates stored in a table field. I can extract just the day fine. For
example, if I have 2/5/04 stored. I can extract the day 5.

Is there a way I can extract and then print on a report the proper extension
to the number that is 1st, 2nd, 3rd, 4th, 5th, etc?

I'm suing Access 2000.


You can use the function below in an expression:

NumberOrdinal(DatePart("d", datefield))

===================================
Public Function NumberOrdinal(ByVal intValue As Long) As
String
If (intValue Mod 100) \ 10 = 1 Then
NumberOrdinal = intValue & "th"
Else
Select Case intValue Mod 10
Case 1
NumberOrdinal = intValue & "st"
Case 2
NumberOrdinal = intValue & "nd"
Case 3
NumberOrdinal = intValue & "rd"
Case 4, 5, 6, 7, 8, 9, 0
NumberOrdinal = intValue & "th"
End Select
End If
End Function
 
Back
Top