First time here - loving the breadth and depth of knowledge on display.
I am hoping that someone may offer some assistance to a relative novice at this kind of thing - I have read Macropod's brilliant date/time document, and it has answered a lot of my questions but......
I am trying to create a Text Form Field in a Word 2007 Document that will accept a user input date (which won't get subsequently updated - but doesn't need to be locked) and I would like the date to be formatted including the ordinal for the day -
eg - 27th July 2010
I can get to the stage where the input is displayed as '27 July 2010' - where I am pulling my hair out is getting the 'th' dropped in there.
In the Text Form Field Options box I have tried appending the \* Ordinal switch after the d - eg d \* Ordinal MMMM YYYY but this doesn't work - I have tried a number of different alternatives, either with or without the curly brackets but nothing seems to work.
I really don't want to resort to VB and Macros - I can't help thinking there is a simple solution which I am somehow missing.
Thanks, in advance, for any suggestions,
With your text formfield, you could mandate a simple 8-digit entry, in the form of DDMMYYYY, then use the following 'MakeOrdinalDate' macro as the formfield's 'on exit' macro:
If Len(.Result) = 8 Then _
If IsDate(Left(.Result, 2) & "/" & Mid(.Result, 3, 2) & "/" & Right(.Result, 4)) Then _
.Result = OrdinalNumber(Left(.Result, 2)) & " " & Format(CDate(Left(.Result, 2) & "/" & Mid(.Result, 3, 2) & "/" & Right(.Result, 4)), "MMMM YYYY")
Function OrdinalNumber(ByVal Num As Long) As String
Dim N As Long
N = Num Mod 100
If ((Abs(N) > 10) And (Abs(N) < 14)) Or ((Abs(N) Mod 10) > 3) Or ((Abs(N) Mod 10) = 0) Then
OrdinalNumber = Format(Num, "0") & Format(Abs(N), "t\h")
OrdinalNumber = Format(Num, "0") & Format(Abs(N) Mod 10 - 2, "r\d;\st;\n\d")