Dates with the Ordinal Suffix

Download the code

Notice this example has an ordinal suffix: Saturday 4th July
Below is the code that will do this.

<%
'Declare variables
Dim curDayOftheWeek, curMonth, curDay
'Return the numeric day of the week Sunday = 1 etc
curDayOftheWeek=(weekday(date))
Select Case curDayOftheWeek
Case 1 Response.write("Sunday")
Case 2 Response.write("Monday")
Case 3 Response.write("Tuesday")
Case 4 Response.write("Wednesday")
Case 5 Response.write("Thursday")
Case 6 Response.write("Friday")
Case 7 Response.write("Saturday")
End select
'Write out the numeric day of the month
Response.Write(" "&day(date))
'Return the numeric day of the month and assign to variable curDay
curDay=day(date)
'Write out the ordinal suffix according to the numeric day of the day
Select Case curDay
Case 1,21,31 response.write("st")
Case 2,22 response.write("nd")
Case 3,23 response.write("rd")
Case else response.write("th")
End select
'add a space
response.write " "
'Return the numeric month of the year and assign to variable curMonth
'1=January, 2=February etc
curMonth=(month(date))
Select Case curMonth
Case 1 Response.write("January")
Case 2 Response.write("February")
Case 3 Response.write("March")
Case 4 Response.write("April")
Case 5 Response.write("May")
Case 6 Response.write("June")
Case 7 Response.write("July")
Case 8 Response.write("August")
Case 9 Response.write("September")
Case 10 Response.write("October")
Case 11 Response.write("November")
Case 12 Response.write("December")
End Select
%>


Other date and time related tutorials:
Read more on the Date, Time and Now VBScript functions
Here's a code snippet to display the day and date (eg. Mon 25 December).
How to get the current month name
Display the dates and times
Time and Date based greetings
IsDate Function
The DateDiff DateAdd and DatePart Functions

ASP/.NET Hosting

asp.netPRO’s “Best ASP.NET Hosting” – Click Here!

MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.