Date format - ex: 7th of November

  • Thread starter Thread starter Aliza Klein
  • Start date Start date
A

Aliza Klein

Hi.

I have a client who wants the current date to print out as:
"??? th/nd day of the month of whatever , the current year".

As in:
2nd day of the month of November, 2004
3rd day....
11th day of the month of November, 2004

I do not see an obvious way of doing this.

Any ideas?
TIA,
Aliza
 
Aliza Klein said:
Hi.

I have a client who wants the current date to print out as:
"??? th/nd day of the month of whatever , the current year".

As in:
2nd day of the month of November, 2004
3rd day....
11th day of the month of November, 2004

I do not see an obvious way of doing this.

While a custom function could probably deal with this I would see if you
can convince him to go to a format like...

day 2 of the month of November, 2004
day 11 of the month of November, 2004
etc...

It's almost exactly the same thing and it eliminates having to deal with
the variable "nth", "st", "rd" issue which is the only difficult part of
what he's asking for.
 
hi
IF format(date,"dd") = 1 then
format(date,"dd")& "st day of the month of " &
Format(date,"mmmm") & ", " & format(date,"yyyy")
else
If format(date,"dd") = 2 then
format(date,"dd")& "nd day of the month of " &
Format(date,"mmmm") & ", " & format(date,"yyyy")
else
format(date,"dd")& "th day of the month of " &
Format(date,"mmmm") & ", " & format(date,"yyyy")
end if
end if
you would have to have a condition of each instance the
the number id changes 1st,21st,31st, 2nd, 22nd ,3rd, 23rd
ect. select case might be better.
 
Rick Brandt said:
While a custom function could probably deal with this I would see if
you can convince him to go to a format like...

day 2 of the month of November, 2004
day 11 of the month of November, 2004
etc...

It's almost exactly the same thing and it eliminates having to deal
with the variable "nth", "st", "rd" issue which is the only difficult
part of what he's asking for.

I happen to have this lying around from a newsgroup question long ago:

'----- start of code -----
Function fncOrdinal(ByVal lngNumber As Long) As String

Dim strNumber As String

strNumber = " " & lngNumber

Select Case Right$(strNumber, 1)
Case "1"
If Right$(strNumber, 2) = "11" Then
strNumber = strNumber & "th"
Else
strNumber = strNumber & "st"
End If
Case "2"
If Right$(strNumber, 2) = "12" Then
strNumber = strNumber & "th"
Else
strNumber = strNumber & "nd"
End If
Case "3"
If Right$(strNumber, 2) = "13" Then
strNumber = strNumber & "th"
Else
strNumber = strNumber & "rd"
End If
Case Else
strNumber = strNumber & "th"
End Select

fncOrdinal = Trim$(strNumber)

End Function
'----- end of code -----
 
Unfortunately, it is for the generation of a legal document so he is kind of
picky!
Aliza
 
THanks!
That should do the trick!
aliza

Dirk Goldgar said:
I happen to have this lying around from a newsgroup question long ago:

'----- start of code -----
Function fncOrdinal(ByVal lngNumber As Long) As String

Dim strNumber As String

strNumber = " " & lngNumber

Select Case Right$(strNumber, 1)
Case "1"
If Right$(strNumber, 2) = "11" Then
strNumber = strNumber & "th"
Else
strNumber = strNumber & "st"
End If
Case "2"
If Right$(strNumber, 2) = "12" Then
strNumber = strNumber & "th"
Else
strNumber = strNumber & "nd"
End If
Case "3"
If Right$(strNumber, 2) = "13" Then
strNumber = strNumber & "th"
Else
strNumber = strNumber & "rd"
End If
Case Else
strNumber = strNumber & "th"
End Select

fncOrdinal = Trim$(strNumber)

End Function
'----- end of code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top