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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding ordinal numbers with "rd" or "th" or "nd" s

Status
Not open for further replies.

mybers

IS-IT--Management
Mar 24, 2004
62
PH
Hello Everyone

I have this Certificate like report where I have a field of [issued date].

My problem is that I would like to have an output something like this: Issued this day of 23rd day of May , 2004.

The source field is set to #5/23/2004#

Is there a way to add "rd" or "th" on this?

Any help would be of great help....

Regards,

mybers


 
You would need to write a function to do this.

Possible answer:

Function DateWithSuffix(vDate)
Dim suffix
Dim xD
xD = Day(vDate)

Select Case xD

Case 1, 21, 31
suffix = "st"
Case 2, 22
suffix = "nd"
Case 3, 23
suffix = "rd"
Case Else
suffix = "th"
End Select

DateWithSuffix = xD & suffix & " day of" & Format(vDate, " MMMM, YYYY")

End Function

Example:
?datewithsuffix("21/03/2003")
21st day of March, 2003





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top