problem with date code, st,th,nd

antonyx

Arsenal Supporter
Local time
Today, 13:59
Joined
Jan 7, 2005
Messages
556
hi. im using the following code to round off my dates but occasionally it goes wrong and displays as

3th

or 11st

etc

can anyone see what is wrong with the following code..

Code:
Dim datelastdigit, ending
datelastdigit = Right(Day([JobDate]), 1)

Select Case datelastdigit
    Case 1
        ending = "st"
    Case 2
        ending = "nd"
    Case 3
        ending = "rd"
    Case Else
        ending = "th"
End Select

displayed as
Code:
If Me.txtjobdate & "" <> "" Then
strBody = strBody & "<tr><td width='185'></td><td width='465'></td></tr><tr><td width='185'><font face='Arial' size='2' color='#666666'><b>Transfer date:</b></td><td width='465'><font face='Arial' size='2' color='#666666'><b> " & Format([JobDate], "dddd") & " " & Format([JobDate], "d") & ending & " " & Format([JobDate], "mmmm yyyy") & "</b></font></td></tr>"
End If
 
why not use the whole day number and code like this

Case 1,21,31
ending = "st"
Case 2,22
ending = "nd"

etc
 
11st
12nd
13rd

are correct results of your code.
3th is a puzzle.

Brian
 

Users who are viewing this thread

Back
Top Bottom