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

Using ordinal numbers (1st, 2nd, 3rd, 4th) in ASP

Status
Not open for further replies.

LaPluma

Programmer
Feb 3, 2002
139
DE
Hello

I have tried some code to try and get the current date to appear as in 1st June 1999, 2nd July 1998, 3rd August 2001, 4th September 1987, but I am having difficulty with it.
This is what I have:

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY BGCOLOR=WHITE>
<FONT FACE=VERDANA COLOR=BLUE SIZE=5>
<LANGUAGE=&quot;VBScript&quot;>

Response.Write WriteDate()

Function Suffix(number)
SELECT CASE Number
CASE 1
temp = &quot;st&quot;
CASE 2
temp = &quot;nd&quot;
case 3
temp = &quot;rd&quot;
CASE ELSE
temp = &quot;th&quot;
END SELECT
Suffix = number & temp
End Function

Function WriteDate(theDate)
WriteDate = Suffix(Day(theDate)) & &quot; &quot; & Monthname(Month(theDate)) & &quot; &quot; & Year(theDate)
End Function
</SCRIPT>
</FONT>
</BODY>
</HTML>

I am unsure about what should be inserted - if anything - in the brackets here:

Response.Write WriteDate(<your date>)

and I probably need to insert (somewhere!) some kind of statement along the following lines:

<%Session.LCID = 2057%>

to force UK time values. Should this be inerted at the very top of the page, or doesn't it matter?

Please let me know what I'm doing wrong.

Best wishes







 
I'm not sure what your problem is, but there's a small bug in your suffix function for the following days:

21st - gives 21th
22nd - gives 22th
31st - gives 31th

Just thought I'd let you know.
 
I'm not sure what your problem is, but there's a small bug in your suffix function for the following days:

21st - gives 21th
22nd - gives 22th
23rd - gives 23th
31st - gives 31th

Just thought I'd let you know.
 
Hello dds82

Many thanks for your post and assistance.
I think I've sorted it our now!

Best wishes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top