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

Dates in Word 1

Status
Not open for further replies.

WingandaPrayer

Technical User
May 15, 2001
152
A simple question I hope.

Is it possible to show the date as 8th November 2002.

The th,rd,st etc are not set in the date formats.


Thanks.
 
Just type it in ...8th, 3rd 1st will appear with the th, rd, st in superscript following the number.

hwyl
Jonsi
 
Hi jonsi,

Thanks for the reply.

As there isn't one available in the custom date/time formats I wanted to know if one could be added to VB Editor to produce todays date with the th,nd etc without having to enter.

"Am I just lazy"

Cheers
 
I thought laziness was a virtue.

Sure, why re-invent the wheel? Here is a macro from MS that creates ordinal dates. You may want to change it a little.

Sub GetOrdinalDates()
Dim fDate As FormField
' If no documents are open or if no form fields
' exist in the active document, or for other
' errors, exit this routine.
On Error GoTo errhandler
' Replace the word Date with the name of your
' form field with your formfield bookmark name.
Set fDate = ActiveDocument.FormFields("Date")
' Is the result of the form field a valid date?
If Not IsDate(fDate.Result) Then Exit Sub
' Determine date format.
Select Case Day(fDate.Result)
Case 1, 21, 31
daysuffix$ = Day(fDate.Result) & "st"
Case 2, 22
daysuffix$ = Day(fDate.Result) & "nd"
Case 3, 23
daysuffix$ = Day(fDate.Result) & "rd"
Case Else
daysuffix$ = Day(fDate.Result) & "th"
End Select

' Use ONE of the following formats.
' Remove the remark(apostrophe) from the
' command lines that produce the desired format.
' -----------------------------------------------

' - Format example: 24th day of February, 1998
' fDate.Result = daysuffix$ & " day of " _
' & Format$(fDate.Result, "mmmm, yyyy")

' - Format example: February 24th, 1998
' fDate.Result = Format$(fDate.Result, "mmmm") & " " & _
' daysuffix$ & Format$(fDate.Result, ", yyyy")

' - Format example: Tuesday the 24th, 1998
' fDate.Result = Format$(fDate.Result, "dddd") & " the " & _
' daysuffix$ & Format$(fDate.Result, ", yyyy")
errhandler:
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top