Return 1st,2nd,3rd,4th from Date 
Author Message
 Return 1st,2nd,3rd,4th from Date


writes
Quote:
>Anyone have a function to return the two character modifiers that can be
>attached to numbers ? I need to attach them to dates. Thank you.

Function ordinal (sz_Number As String) As String
' Returns "st", "nd", "rd", "th" for string values 1 - ...9

If Len(sz_Number) > 1 And Left$(Right$(sz_Number, 2), 1) = "1" Then
    ordinal = "th"
Else
    Select Case Right$(sz_Number, 1)
        Case "1"
            ordinal = "st"
        Case "2"
            ordinal = "nd"
        Case "3"
            ordinal = "rd"
        Case Else
            ordinal = "th"
    End Select
End If
End Function
--



Tue, 23 Oct 2001 03:00:00 GMT  
 Return 1st,2nd,3rd,4th from Date

Quote:

>This will work for numbers, you'll need to change datatypes for dates:
>Public Function Ordinal(ByVal X As Integer) As String
>    Select Case Abs(X Mod 10)
>        Case 1: Ordinal = X & IIf(Right(X, 2) = 11, "th", "st")
>        Case 2: Ordinal = X & IIf(Right(X, 2) = 12, "th", "nd")
>        Case 3: Ordinal = X & IIf(Right(X, 2) = 13, "th", "rd")
>        Case Else: Ordinal = X & "th"
>    End Select
>End Function

I wonder if the "th", "st", "nd", "rd" strings and the rules for applying
them are in the regionalization settings. As for using this on dates, it'll
probably be a call like Ordinal(Day(Whenever)).

--

WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Thu, 25 Oct 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Postions - 1st 2nd 3rd 4th etc

2. Displaying: date: 1st, 2nd, 3rd, 11th, 21st

3. Microsof publisher How to print 2nd 3rd and 4th quarter of page

4. Get 1st, 2nd, and 3rd Letter From a String

5. 1st box<2nd box<3rd box?

6. 1st month, 2nd month, 3rd month...

7. If 1st cell is empty, I want data from 2nd cell to copy into 3rd cell

8. Displaying Day as 1st, 2nd, 3rd, etc.

9. Close 2nd form and return to 1st form

10. Triggering 2nd show on 2nd PC from 1st show


 
Powered by phpBB® Forum Software © phpBB Group