Formatting Date

L

Lee Kiwiflame

I have a calendar control on my userform and I need to place the date in
three different formats.

I know how to code 2 of them:
1. The first is 20 September 2008 (dd mmmm yyyy).
2. The second is 20/09/2008 (dd/mm/yyyy).

However, it's the third one I am stuck on. I need the date to be placed
into the document as "20th day of September 2008".

How would you code putting the "th day of" or "st day of" or "rd say of"
(e.g. 20th day of September, 21st day of September or 23rd day of September)
from a calendar control? I only want to select one date.

Any help is very aprpeciated.
 
G

Graham Mayor

How about

Dim strTemp As String
Dim tdate As Date
Dim lngDay As Long

tdate = Now()
lngDay = Day(tdate)

If ((lngDay Mod 100) > 10) And ((lngDay Mod 100) <= 14) Then
strTemp = "th"
Else
Select Case (lngDay Mod 10) + 1
Case 2
strTemp = "st"
Case 3
strTemp = "nd"
Case 4
strTemp = "rd"
Case Else
strTemp = "th"
End Select
strTemp = strTemp & " day of "
End If
MsgBox CStr(lngDay) & strTemp & format$(tdate, "mmmm yyyy")


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top